Centos

在 CentOS 7 上使用 Pagespeed 編譯 Nginx 時出錯

  • December 30, 2019

我正在嘗試使用 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++ 庫:

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 whatprovides <library>在哪個軟體包中可用,並確保您已全部安裝。

編輯:您的選擇很重要。例如 ssp 將限制 stackoverflow 攻擊並具有安全目的。其他選項將優化二進製文件,使其最適合您的目標架構。

退後一步後,我覺得很奇怪,通過更改這些選項它會在外部庫上崩潰。不管怎樣,你按照我們之前討論的步驟進行操作很好,這樣你就有了從 nginx 中獲得最佳性能所需的庫(請記住,它是事件驅動的,所以 libevent 是必須的!)。

您的實際問題來自您傳遞--params給配置呼叫的方式。您正試圖在字元串本身內的新行上拆分。

--with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector \ 
--param=ssp-buffer-size=4 -m64 -mtune=generic' \

應該 :

--with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' \

然後為文字牆做好準備:)

引用自:https://serverfault.com/questions/636538