我正在尝试使用 Pagespeed 从源代码编译 Nginx,并且我很难解决not found
添加配置设置时看到的错误。这是我的配置设置:
我正在使用 CentOS 7 - 64 位
配置设置:
sudo ./configure --add-module=/nginx-compile/modules/ngx_pagespeed-release-1.9.32.1-beta \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-ipv6 \
--with-http_spdy_module \
--with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector \
--param=ssp-buffer-size=4 -m64 -mtune=generic' \
--user=nginx \
--group=nginx
当我在 ssh 中添加上述内容时,我收到以下not found
错误和no supported file AIO was found
错误。这是我得到的清单:
执行配置后的错误:
checking for OS
+ Linux 3.10.0-123.el7.x86_64 x86_64
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC)
checking for gcc -pipe switch ... found
checking for gcc builtin atomic operations ... not found
checking for C99 variadic macros ... not found
checking for gcc variadic macros ... not found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux specific features
checking for epoll ... not found
checking for O_PATH ... not found
checking for sendfile() ... not found
checking for sendfile64() ... not found
checking for sys/prctl.h ... found
checking for prctl(PR_SET_DUMPABLE) ... not found
checking for sched_setaffinity() ... not found
checking for crypt_r() ... not found
checking for sys/vfs.h ... found
checking for poll() ... not found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... not found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... not found
checking for O_DIRECT ... not found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for statfs() ... not found
checking for statvfs() ... not found
checking for dlopen() ... not found
checking for dlopen() in libdl ... not found
checking for sched_yield() ... not found
checking for sched_yield() in librt ... not found
checking for SO_SETFIB ... not found
checking for SO_ACCEPTFILTER ... not found
checking for TCP_DEFER_ACCEPT ... not found
checking for TCP_KEEPIDLE ... not found
checking for TCP_FASTOPEN ... not found
checking for TCP_INFO ... not found
checking for accept4() ... not found
checking for kqueue AIO support ... not found
checking for Linux AIO support ... not found
./configure: no supported file AIO was found
Currently file AIO is supported on FreeBSD 4.3+ and Linux 2.6.22+ only
在添加配置设置之前,我还安装了以下依赖项:
sudo yum install gcc gcc-c++ pcre-devel zlib-devel make unzip openssl-devel
我使用的配置类似于我使用 centos 内置 repo 安装 Nginx 时的配置设置,只是它添加了 pagespeed 模块。
更新:
实际问题是我在将--params
配置调用传递给不正确并导致错误时拆分线路的方式。感谢@XavierLucas下面的回答,一旦我添加--with-cc-opt
并--params
在 1 行中,错误就解决了。
扩展:
虽然以上是导致错误的原因,但我还了解到,为了让 Nginx 充分利用其核心功能并安装 pagespeed 模块,安装以下库也很好:
gcc
gcc-c++
pcre-devel
zlib-devel
make
unzip
openssl-devel
libaio-devel
glibc
glibc-devel
glibc-headers
libevent
linux-vdso.so.1
libpthread.so.0
libcrypt.so.1
libstdc++.so.6
librt.so.1
libm.so.6
libpcre.so.0
libssl.so.10
libcrypto.so.10
libdl.so.2
libz.so.1
libgcc_s.so.1
libc.so.6
/lib64/ld-linux-x86-64.so.2
libfreebl3.so
libgssapi_krb5.so.2
libkrb5.so.3
libcom_err.so.2
libk5crypto.so.3
libkrb5support.so.0
libkeyutils.so.1
libresolv.so.2
libselinux.so.1
和
yum groupinstall 'Development Tools'
为了停止一些冗长的聊天,这里是 CentOS 上具有 pagespeed 的 nginx 编译版本所需的 C/C++ 库:
检查它
yum whatprovides <library>
在哪个软件包中可用,并确保您已全部安装。编辑:您的选择很重要。例如 ssp 将限制 stackoverflow 攻击并具有安全目的。其他选项将优化二进制文件,使其最适合您的目标架构。
退后一步后,我觉得很奇怪,通过更改这些选项它会在外部库上崩溃。不管怎样,你按照我们之前讨论的步骤进行操作很好,这样你就有了从 nginx 中获得最佳性能所需的库(请记住,它是事件驱动的,所以 libevent 是必须的!)。
您的实际问题来自您传递
--params
给配置调用的方式。您正试图在字符串本身内的新行上拆分。应该 :
然后为文字墙做好准备:)
这是在 CentOS 7 中使用 pagespeed 1.11.33.4 编译 nginx 1.10.2 的方法
https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source
转到此页面以查找最新版本
-beta 不代表不稳定版本,1.11.33.4 是稳定版本
通用配置(从 repo + pagespeed 安装的 nginx)
然后
制作文件并粘贴代码:
检查 /var/ngx_pagespeed_cache 文件夹是否由 nginx 创建
编辑 /etc/nginx/your-domain.conf ### 并放置您的设置
测试配置
警告!禁用您的 repo 以防止 nginx 更新!
试试这个来安装我们的基本依赖,运行:
RedHat、CentOS 或 Fedora
sudo yum install gcc-c++ pcre-devel zlib-devel make unzip libuuid-devel
Ubuntu 或 Debian
sudo apt-get install build-essential zlib1g-dev libpcre3 libpcre3-dev unzip uuid-dev
参考:https ://www.modpagespeed.com/doc/build_ngx_pagespeed_from_source
不适用于 Centos 7、nginx 1.16.1:
……