AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 636538
Accepted
Neel
Neel
Asked: 2014-10-14 00:46:11 +0800 CST2014-10-14 00:46:11 +0800 CST 2014-10-14 00:46:11 +0800 CST

在 CentOS 7 上使用 Pagespeed 编译 Nginx 时出错

  • 772

我正在尝试使用 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
  • 4 4 个回答
  • 8900 Views

4 个回答

  • Voted
  1. Best Answer
    Xavier Lucas
    2014-10-14T07:04:08+08:002014-10-14T07:04:08+08:00

    为了停止一些冗长的聊天,这里是 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' \
    

    然后为文字墙做好准备:)

    • 3
  2. Dimitrios
    2016-12-20T09:23:16+08:002016-12-20T09:23:16+08:00

    这是在 CentOS 7 中使用 pagespeed 1.11.33.4 编译 nginx 1.10.2 的方法

    yum update
    yum install wget curl gcc-c++ pcre-devel zlib-devel make unzip openssl-devel
    
    mkdir /root/custom-nginx
    cd /root/custom-nginx
    
    NGINX_VERSION=1.10.2          ### copy and paste, place your nginx version you want to install
    
    wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
    
    tar zxvf nginx-${NGINX_VERSION}.tar.gz
    
    ls -la ### check downloaded version
    
    cd /root/custom-nginx/nginx-${NGINX_VERSION}/src/http/modules/
    

    https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source

    转到此页面以查找最新版本

    -beta 不代表不稳定版本,1.11.33.4 是稳定版本

    NPS_VERSION=1.11.33.4        ### copy and paste, place your pagespeed version you want to install
    
    wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip -O release-${NPS_VERSION}-beta.zip
    
    unzip release-${NPS_VERSION}-beta.zip
    
    mv ngx_pagespeed-release-${NPS_VERSION}-beta ngx_pagespeed
    cd ngx_pagespeed
    
    wget https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz
    tar -xzvf ${NPS_VERSION}.tar.gz
    
    cd /root/custom-nginx/nginx-${NGINX_VERSION}/
    

    通用配置(从 repo + pagespeed 安装的 nginx)

    ./configure --add-module=/root/custom-nginx/nginx-${NGINX_VERSION}/src/http/modules/ngx_pagespeed --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --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 --user=nginx --group=nginx --with-file-aio --with-threads --with-ipv6 --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_ssl_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic'
    
    
    make && make install
    

    然后

    nano /etc/init.d/nginx
    

    制作文件并粘贴代码:

    #!/bin/sh
    #
    # nginx - this script starts and stops the nginx daemon
    #
    # chkconfig:   - 85 15
    # description:  NGINX is an HTTP(S) server, HTTP(S) reverse \
    #               proxy and IMAP/POP3 proxy server
    # processname: nginx
    # config:      /etc/nginx/nginx.conf
    # config:      /etc/sysconfig/nginx
    # pidfile:     /var/run/nginx.pid
    
    # Source function library.
    . /etc/rc.d/init.d/functions
    
    # Source networking configuration.
    . /etc/sysconfig/network
    
    # Check that networking is up.
    [ "$NETWORKING" = "no" ] && exit 0
    
    nginx="/usr/sbin/nginx"
    prog=$(basename $nginx)
    
    NGINX_CONF_FILE="/etc/nginx/nginx.conf"
    
    [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
    
    lockfile=/var/lock/subsys/nginx
    
    make_dirs() {
       # make required directories
       user=`$nginx -V 2>&1 | grep "configure arguments:.*--user=" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
       if [ -n "$user" ]; then
          if [ -z "`grep $user /etc/passwd`" ]; then
             useradd -M -s /bin/nologin $user
          fi
          options=`$nginx -V 2>&1 | grep 'configure arguments:'`
          for opt in $options; do
              if [ `echo $opt | grep '.*-temp-path'` ]; then
                  value=`echo $opt | cut -d "=" -f 2`
                  if [ ! -d "$value" ]; then
                      # echo "creating" $value
                      mkdir -p $value && chown -R $user $value
                  fi
              fi
           done
        fi
    }
    
    start() {
        [ -x $nginx ] || exit 5
        [ -f $NGINX_CONF_FILE ] || exit 6
        make_dirs
        echo -n $"Starting $prog: "
        daemon $nginx -c $NGINX_CONF_FILE
        retval=$?
        echo
        [ $retval -eq 0 ] && touch $lockfile
        return $retval
    }
    
    stop() {
        echo -n $"Stopping $prog: "
        killproc $prog -QUIT
        retval=$?
        echo
        [ $retval -eq 0 ] && rm -f $lockfile
        return $retval
    }
    
    restart() {
        configtest || return $?
        stop
        sleep 1
        start
    }
    
    reload() {
        configtest || return $?
        echo -n $"Reloading $prog: "
        killproc $nginx -HUP
        RETVAL=$?
        echo
    }
    
    force_reload() {
        restart
    }
    
    configtest() {
      $nginx -t -c $NGINX_CONF_FILE
    }
    
    rh_status() {
        status $prog
    }
    
    rh_status_q() {
        rh_status >/dev/null 2>&1
    }
    
    case "$1" in
        start)
            rh_status_q && exit 0
            $1
            ;;
        stop)
            rh_status_q || exit 0
            $1
            ;;
        restart|configtest)
            $1
            ;;
        reload)
            rh_status_q || exit 7
            $1
            ;;
        force-reload)
            force_reload
            ;;
        status)
            rh_status
            ;;
        condrestart|try-restart)
            rh_status_q || exit 0
                ;;
        *)
            echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
            exit 2
    esac
    

    检查 /var/ngx_pagespeed_cache 文件夹是否由 nginx 创建

    编辑 /etc/nginx/your-domain.conf ### 并放置您的设置

    ###PAGESPEED###
    pagespeed on;
    pagespeed FileCachePath /var/ngx_pagespeed_cache;
    ##EXTRA FILTERS
    #--> JAVASCRIPT
    pagespeed EnableFilters canonicalize_javascript_libraries,rewrite_javascript,combine_javascript,inline_javascript,make_google_analytics_async ;
    #--> CSS
    pagespeed EnableFilters move_css_above_scripts,move_css_to_head,rewrite_style_attributes,inline_css,inline_google_font_css ;
    #--> IMAGES
    pagespeed EnableFilters convert_to_webp_lossless,sprite_images,resize_mobile_images,inline_preview_images ;
    #--> HTML
    pagespeed EnableFilters collapse_whitespace,remove_comments,extend_cache ;
    #
    ##EXTRA MODS
    pagespeed LazyloadImagesAfterOnload off ;
    pagespeed UseExperimentalJsMinifier on ;
    pagespeed LowercaseHtmlNames on ;
    pagespeed PreserveUrlRelativity on ;
    pagespeed XHeaderValue "Modified By dimitrios" ;
    #pagespeed ForceCaching on ;
    ###PAGESPEED###
    

    测试配置

    /usr/sbin/nginx -V  ### must include pagespeed
    /usr/sbin/nginx -t  ### syntax must be ok
    

    警告!禁用您的 repo 以防止 nginx 更新!

    • 1
  3. Nadeeshan Herath
    2018-08-30T23:01:28+08:002018-08-30T23:01:28+08:00

    试试这个来安装我们的基本依赖,运行:

    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

    • 0
  4. gdm
    2019-12-31T03:38:10+08:002019-12-31T03:38:10+08:00

    不适用于 Centos 7、nginx 1.16.1:

    [root@aru-251736 nginx-1.16.1]# ./configure --add-module=../ModSecurity-nginx \
    --prefix=/usr/share/nginx \
    --sbin-path=/usr/sbin/nginx \
    --modules-path=/usr/lib64/nginx/modules \
    --conf-path=/etc/nginx/nginx.conf \
    --error-log-path=/var/log/nginx/error.log \
    --http-log-path=/var/log/nginx/access.log \
    --http-client-body-temp-path=/var/lib/nginx/tmp/client_body \
    --http-proxy-temp-path=/var/lib/nginx/tmp/proxy \
    --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi \
    --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi \
    --http-scgi-temp-path=/var/lib/nginx/tmp/scgi \
    --pid-path=/run/nginx.pid \
    --lock-path=/run/lock/subsys/nginx \
    --with-file-aio \
    --with-ipv6 \
    --with-http_ssl_module \
    --with-http_v2_module \
    --with-http_realip_module \
    --with-stream_ssl_preread_module --with-http_addition_module \
    --with-http_xslt_module=dynamic \
    --with-http_image_filter_module=dynamic \
    --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_degradation_module \
    --with-http_slice_module \
    --with-http_stub_status_module \
    --with-http_perl_module=dynamic \
    --with-http_auth_request_module \
    --with-mail=dynamic \
    --with-mail_ssl_module \
    --with-pcre --with-pcre-jit \
    --with-stream=dynamic \
    --with-stream_ssl_module \
    --with-google_perftools_module \
    --with-debug \
    --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' 
    

    ……

    checking for IP_PKTINFO ... not found
    checking for IPV6_RECVPKTINFO ... 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
    checking for Linux AIO support (SYS_eventfd) ... not found
    
    ./configure: no supported file AIO was found
    Currently file AIO is supported on FreeBSD 4.3+ and Linux 2.6.22+ only
    
    • 0

相关问题

  • 如何在 Linux 机器上找到有关硬件的详细信息?

  • 使用 crontab 和 /etc/cron.hourly,daily,weekly 的区别

  • 持续监控许多服务器运行状况的简单方法?

  • Hudson 无法在 tomcat5 中启动

  • CentOS 的依赖挑战

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve