我想使用ngx_pagepeed模块。由于我的服务器上已经设置了 nginx,因此我先将其删除,然后使用以下命令再次编译它。
sudo apt-get remove --purge nginx
sudo apt-get autoremove
sudo apt-get autoclean
我按照给出的说明构建了一个支持 PageSpeed 的新 Nginx 二进制文件这里。
whereis nginx
输出如下
nginx: /usr/sbin/nginx /etc/nginx /usr/local/sbin/nginx /usr/local/nginx /usr/share/nginx /usr/share/man/man1/nginx.1.gz
nginx -V
以下是该命令的输出
nginx version: nginx/1.10.1
built by gcc 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
configure arguments: --add-module=/root/ngx_pagespeed-release-1.11.33.4-beta --prefix=/usr/local/share/nginx --conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/local/sbin --error-log-path=/var/log/nginx/error.log --with-ipv6
的输出/usr/sbin/nginx -V
是
nginx version: nginx/1.4.6 (Ubuntu)
built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --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_realip_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module
我nginx.conf
使用 pagespeed 模块设置更新了我的文件,并尝试使用sudo service restart nginx
它重新启动 nginx 服务器,结果显示* Restarting nginx nginx [fail]
:
如果我使用它测试我的新 nginx 设置,nginx -t
它说配置很好
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
但是我在错误日志中发现了这一点
[emerg] 24452#0: unknown directive "pagespeed" in /etc/nginx/nginx.conf:65
我读到过一些文章说运行以下命令可以启动正确的 nginx - sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
。这给出了以下输出
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
由于某种原因,我的旧 nginx 二进制文件仍在运行,并且不允许新二进制文件启动。我该如何运行新二进制文件?
答案1
killall -9 nginx
然后启动本地的。