删除Nginx并使用Pagespeed模块安装Nginx

时间:2017-01-17 17:48:36

标签: ubuntu nginx upgrade pagespeed

所以我刚安装了一个带有Ubuntu 16.04 LTS的新Linode,我安装了Nginx 1.10.0

nginx -v
nginx version: nginx/1.10.0 (Ubuntu)

我按照谷歌的说明安装了新版本的Nginx并添加了这里描述的Pagespeed模块:https://modpagespeed.com/doc/build_ngx_pagespeed_from_source

当我执行nginx -v时,仍然安装了以前的版本,并且我有一个新文件夹,其中包含nginx nginx-1.11.8!如何删除以前的版本并安装pagespeed?很困惑。

更新

我尝试安装动态模块,然后在重新编译时得到这个:

  sudo make install
    make -f objs/Makefile install
    make[1]: Entering directory '/home/henri/nginx-1.10.0'
test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
test -d '/usr/local/nginx/sbin' \
    || mkdir -p '/usr/local/nginx/sbin'
test ! -f '/usr/local/nginx/sbin/nginx' \
    || mv '/usr/local/nginx/sbin/nginx' \
        '/usr/local/nginx/sbin/nginx.old'
cp objs/nginx '/usr/local/nginx/sbin/nginx'
test -d '/usr/local/nginx/conf' \
    || mkdir -p '/usr/local/nginx/conf'
cp conf/koi-win '/usr/local/nginx/conf'
cp conf/koi-utf '/usr/local/nginx/conf'
cp conf/win-utf '/usr/local/nginx/conf'
test -f '/usr/local/nginx/conf/mime.types' \
    || cp conf/mime.types '/usr/local/nginx/conf'
cp conf/mime.types '/usr/local/nginx/conf/mime.types.default'
test -f '/usr/local/nginx/conf/fastcgi_params' \
    || cp conf/fastcgi_params '/usr/local/nginx/conf'
cp conf/fastcgi_params \
    '/usr/local/nginx/conf/fastcgi_params.default'
test -f '/usr/local/nginx/conf/fastcgi.conf' \
    || cp conf/fastcgi.conf '/usr/local/nginx/conf'
cp conf/fastcgi.conf '/usr/local/nginx/conf/fastcgi.conf.default'
test -f '/usr/local/nginx/conf/uwsgi_params' \
    || cp conf/uwsgi_params '/usr/local/nginx/conf'
cp conf/uwsgi_params \
    '/usr/local/nginx/conf/uwsgi_params.default'
test -f '/usr/local/nginx/conf/scgi_params' \
    || cp conf/scgi_params '/usr/local/nginx/conf'
cp conf/scgi_params \
    '/usr/local/nginx/conf/scgi_params.default'
test -f '/usr/local/nginx/conf/nginx.conf' \
    || cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf'
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs' \
    || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' \
    || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html' \
    || cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' \
    || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/modules' \
    || mkdir -p '/usr/local/nginx/modules'
test ! -f '/usr/local/nginx/modules/ngx_pagespeed.so' \
    || mv '/usr/local/nginx/modules/ngx_pagespeed.so' \
        '/usr/local/nginx/modules/ngx_pagespeed.so.old'
cp objs/ngx_pagespeed.so '/usr/local/nginx/modules/ngx_pagespeed.so'
make[1]: Leaving directory '/home/henri/nginx-1.10.0'

However I do not see the module!
nginx -V output:

nginx version: nginx/1.10.0 (Ubuntu)
built with OpenSSL 1.0.2g  1 Mar 2016
TLS SNI support enabled

配置参数: - with-cc-opt =' -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror = format-security -Wdate-time -D_FORTIFY_SOURCE = 2' --with-ld-opt =' -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' --prefix = / usr / share / nginx --conf-path = / etc / nginx / nginx.conf --http-log-path = / var / log / nginx / access.log --error-log-path = /var/log/nginx/error.log --lock-path = / var / lock / nginx.lock --pid-path = / run / nginx.pid --http-client-body-temp-path = / var / lib / nginx / body --http-fastcgi-temp-path = / var / lib / nginx / fastcgi --http-proxy-temp-path = / var / lib / nginx / proxy --http-scgi-temp- path = / var / lib / nginx / scgi --http-uwsgi-temp-path = / var / lib / nginx / uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_auth_request_module --with-http_auth_request_module --with-http_adav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads --add-module = / build / nginx-pzhfc2 / nginx- 1.10.0 / debian / modules / nginx-auth-pam --add-module = / buil d / nginx-pzhfc2 / nginx-1.10.0 / debian / modules / nginx-dav-ext-module --add-module = / build / nginx-pzhfc2 / nginx-1.10.0 / debian / modules / nginx-echo - -add-module = / build / nginx-pzhfc2 / nginx-1.10.0 / debian / modules / nginx-upstream-fair --add-module = / build / nginx-pzhfc2 / nginx-1.10.0 / debian / modules / ngx_http_substitutions_filter_module

3 个答案:

答案 0 :(得分:2)

要构建ngx_pagespeed.so(动态模块)的二进制兼容版本,您可能需要将--with-cc-opt="-DNGX_HTTP_HEADERS"'添加到nginx的配置行。 nginx -V的输出不会暗示,但官方稳定的ppa 似乎需要它(我检查了1.12.1)。

有关更多背景信息,请参阅https://github.com/pagespeed/ngx_pagespeed/issues/1440#issuecomment-315520779

奥托

答案 1 :(得分:0)

apt-get remove nginx应该从Ubuntu存储库中删除您安装的版本。

作为替代方案,我建议使用-m选项将pagespeed安装为动态模块。这样你可以保持你从Ubuntu安装的NGINX,只需编译并加载pagespeed。有关page的完整说明。

答案 2 :(得分:0)

2天后......我最终发现了我做错了什么。按照说明操作时,您需要使用当前版本中相同的扩展名重新配置nginx(nginx -V将为您提供所有已安装的扩展名)。添加动态模块后,您可以按照说明将其包含在文件中。