I originally installed nginx like:
apt-get install python-software-properties
add-apt-repository ppa:nginx/stable
apt-get update && apt-get --yes upgrade
apt-get install nginx
and I wanted to add a new module to it, so I tried the following instructions from Recompile NGINX with "--with-http_stub_status_module" configure line "Download the source from nginx.org and unpack it. Use/path/to/your/nginx/binary -V to get your current configure line. Modify it as you see fit, and run the configure file from the nginx source with your new configure line. Then run make, make install and make upgrade and you're all updated."
I created a directory /srv/software/nginx-src/ than
wget http://nginx.org/download/nginx-1.1.5.tar.gz
tar -xzf nginx-1.1.5.tar.gz
./configure --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_gzip_static_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/srv/software/nginx-modules/ngx_cache_purge-1.4
make
make install
make upgrade
everything worked, however, my nginx -v still shows:
nginx: nginx version: nginx/1.0.10
nginx: TLS SNI support enabled
nginx: configure arguments: --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/build/buildd/nginx-1.0.10/debian/modules/nginx-echo --add-module=/build/buildd/nginx-1.0.10/debian/modules/nginx-upstream-fair
It is not updating.... lastly, I tried to uninstall it completely apt-get remove --purge which I think worked, but I am not sure. I can not seem to get the right version to work and now I am worry my server is borked! fml. any help, would be great right now.
Update (1): after finding this guide http://articles.slicehost.com/2009/3/4/ubuntu-intrepid-installing-nginx-from-source and @limon help below I setup the following:
./configure --sbin-path=/usr/local/sbin/nginx --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_gzip_static_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/srv/software/nginx-modules/ngx_cache_purge-1.4
make
make install
i ran which version
root@www:/srv/software/nginx-src/nginx-1.1.5# which nginx
/usr/local/sbin/nginx
but when i try to start it, it will not work
root@www:/srv/software/nginx-src/nginx-1.1.5# sudo /usr/local/sbin/nginx
nginx: [emerg] mkdir() "/var/lib/nginx/body" failed (2: No such file or directory)
Update (2): after reading Limon's commend I needed to create a few directories in /var/lib: mkdir -p /var/lib/nginx/body mkdir -p /var/lib/nginx/proxy mkdir -p /var/lib/nginx/fastcgi mkdir -p /var/lib/nginx/uwsgi mkdir -p /var/lib/nginx/sc
I created these directories and ran sudo /usr/local/sbin/nginx my nginx was now correctly reporting the following:
nginx: nginx version: nginx/1.1.5
nginx: built by gcc 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)
nginx: TLS SNI support enabled
nginx: configure arguments: --sbin-path=/usr/local/sbin/nginx --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_gzip_static_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/srv/software/nginx-modules/ngx_cache_purge-1.4
since my configuration was using jugledisc I pulled my old init.d off of a backup and changed it to point to the correct location.
Since you didn't remove the deb package before compiling the new version from source, it is likely you had multiple versions of the nginx binary installed on the server - to check which one you are calling you can use the 'which' utility like this:
At this point I would use use:
And then reinstall nginx from source.