0

I wanted to set up nginx with the ngx_pagepeed module. Since I already had nginx set up on my server I removed it before compiling it again using the following commands.

sudo apt-get remove --purge nginx
sudo apt-get autoremove
sudo apt-get autoclean

I built a new nginx binary with pagespeed support using the instructions given here.

whereis nginx gives the following output

nginx: /usr/sbin/nginx /etc/nginx /usr/local/sbin/nginx /usr/local/nginx /usr/share/nginx /usr/share/man/man1/nginx.1.gz

Following is the output of the nginx -V command

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

The output of /usr/sbin/nginx -V is

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

I updated my nginx.conf file withe pagespeed module settings and tried to restart the nginx server using sudo service restart nginx which gives me * Restarting nginx nginx [fail].

If I test my new nginx settings using nginx -t it says the configuration is fine

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

However I find this in the error logs

[emerg] 24452#0: unknown directive "pagespeed" in /etc/nginx/nginx.conf:65

I read somewhere to run the following command to start the correct nginx - sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf. This gives me the following output

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()

For some reason my old nginx binary is still running and it's not letting the new binary to start. How do I run the new binary instead?

Yin Yang
  • 273
  • 2
  • 12

1 Answers1

1

killall -9 nginx then start your local one.

drookie
  • 8,051
  • 1
  • 17
  • 27