0

Installed nginx 0.8.54 with apt-get from ubuntu repo. Executing command "passenger-install-nginx-module" installed nginx 1.0.6 (I believe). After restart however, nginx -v still shows version 0.8.54. How to fire up the nginx 1.0.6?

Here is the error when starting nginx under /opt/nginx/sbin which is 1.0.6 (after stop the current nginx server):

    dtt@ubuntu:/etc$ sudo /opt/nginx/sbin/nginx 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() 

Thanks.

user938363
  • 97
  • 2
  • 11

1 Answers1

1

Executing command passenger-install-nginx-module installed nginx 1.0.6 (I believe)

If you pay attention to the installation process, you will see that, by default it install Nginx with --prefix=/opt/nginx, so you must use the absolute path:

$ /opt/nginx/sbin/nginx -v
nginx: nginx version: nginx/1.0.6

$ /opt/nginx/sbin/nginx -V 
nginx: nginx version: nginx/1.0.6 
nginx: built by gcc 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4) 
nginx: TLS SNI support enabled 
nginx: configure arguments: --prefix=/opt/nginx --with-http_ssl_module --with-cc-opt=-Wno-error --add-module=/home/dtt/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/ext/nginx

Why did you said it still shows 0.8.54?

How to start the nginx 1.0.6?

Stop the Nginx 0.8.54 first:

# /etc/init.d/nginx stop

or:

# /usr/sbin/nginx -s stop

and start Nginx 1.0.6 with:

# /opt/nginx/sbin/nginx

Don't forget to edit the init script to the new binary and configuration, something like this:

start() {
    configtest || return 1
    ebegin "Starting nginx"
    start-stop-daemon --start --pidfile /var/run/nginx.pid \
        --exec /opt/nginx/sbin/nginx -- -c /opt/nginx/conf/nginx.conf
    eend $? "Failed to start nginx"
}
quanta
  • 51,413
  • 19
  • 159
  • 217
  • Yes, it is exactly the same output when typing nginx -v. How to start the nginx 1.0.6? The output is still 0.8.54 when typing nginx -v and I assume nginx is running version of 0.8.54. – user938363 Nov 02 '11 at 01:05
  • the output of 'which nginx' is : /usr/sbin/nginx. This is the ver 0.8.54 – user938363 Nov 02 '11 at 01:24
  • Append a snippet of output when installing to make sure that it is installed successfully. Also show us `/opt/nginx/sbin/nginx -V` and `$ tree -L 3 /opt/nginx/`? – quanta Nov 02 '11 at 02:23
  • dtt@ubuntu:/usr/sbin$ /opt/nginx/sbin/nginx -V nginx: nginx version: nginx/1.0.6 nginx: built by gcc 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4) nginx: TLS SNI support enabled nginx: configure arguments: --prefix=/opt/nginx --with-http_ssl_module --with-cc-opt=-Wno-error --add-module=/home/dtt/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9/ext/nginx – user938363 Nov 02 '11 at 02:31
  • dtt@ubuntu:/usr/sbin$ tree -L 3 /opt/nginx/? /opt/nginx/? [error opening dir] 0 directories, 0 files – user938363 Nov 02 '11 at 02:33
  • The above 2 are output of /opt/nginx/sbin/nginx -V and tree -L 3 /opt/nginx/? – user938363 Nov 02 '11 at 02:35
  • updated my answer. – quanta Nov 02 '11 at 02:48
  • dtt@ubuntu:/etc$ sudo /opt/nginx/sbin/nginx 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() – user938363 Nov 02 '11 at 03:27
  • The above is the error output of sudo /opt/nginx/sbin/nginx. I am new to both ubuntu and nginx. Not sure where is wrong. Thanks. – user938363 Nov 02 '11 at 03:27
  • You should edit your original post to append output to keep formatting. The above error means that you hadn't stopped the old version or there is another process is listening on port 80. – quanta Nov 02 '11 at 03:30
  • let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/1712/discussion-between-user938363-and-quanta) – user938363 Nov 02 '11 at 17:24
  • Just verified that 1.0.6 is the running copy. Used sudo lsof -i:80 to find the pid on port 80 and kill it before start 1.0.6 with /opt/nginx/sbin/nginx – user938363 Nov 02 '11 at 19:33