Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How to update nginx with adding module without deleting old nginx files/configs?

I installed nginx with apt-get install, i tried install by downloading tar.gz from nginx site but it doesnt gave any effect.

I'm using debian 6.0.2 squeeze

I would be grateful for advice.

Best Regards

share|improve this question

1 Answer 1

up vote 1 down vote accepted

If you want new modules, you'll have to recompile your nginx. If you want to install it from source, you'll have to remove the Debian package first. Here's a short tutorial for you. I'm performing everything as root user in the following:

Create a backup of your configuration files:

mkdir ~/nginx-config-backup && cp -r /etc/nginx/* ~/nginx-config-backup

Remove previous nginx installation:

apt-get remove nginx*

You'll need this to build nginx from source:

apt-get install build-essentials

The directory where we'll put the source files:

cd /usr/local/src

Get latest development version of nginx:

wget http://nginx.org/download/nginx-1.3.9.tar.gz
tar -zxvf nginx-1.3.9.tar.gz
mv nginx-1.3.9 nginx
rm -f nginx-1.3.9.tar.gz

Get latest PCRE version:

cd ../../lib
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz
tar -zxvf pcre-8.31.tar.gz
mv pcre-8.31 pcre
rm -f pcre-8.31.tar.gz

Get latest OpenSSL version:

wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
tar -zxvf openssl-1.0.1c.tar.gz
mv openssl-1.0.1c openssl
rm -f openssl-1.0.1c.tar.gz

Get latest zlib version:

git clone git://github.com/madler/zlib.git

Now I download two example modules for nginx:

cd ../includes
git clone git://github.com/masterzen/nginx-upload-progress-module.git
git clone git://github.com/gnosek/nginx-upstream-fair.git

Back to nginx; we configure our installation and compile + install it:

cd ../src/nginx
./configure
  --prefix=/usr/local
  --sbin-path=/usr/local/sbin
  --conf-path=/etc/nginx/nginx.conf
  --pid-path=/var/run/nginx.pid
  --lock-path=/var/lock/nginx.lock
  --error-log-path=/var/log/nginx/error.log
  --http-log-path=/var/log/nginx/access.log
  --user=nginx
  --group=nginx
  --with-debug
  --with-file-aio
  --with-http_gzip_static_module
  --with-http_realip_module
  --with-http_ssl_module
  --with-md5=/usr/local/lib/openssl
  --with-md5-asm
  --with-openssl=/usr/local/lib/openssl
  --with-sha1=/usr/local/lib/openssl
  --with-sha1-asm
  --with-pcre=/usr/local/lib/pcre
  --with-pcre-jit
  --with-zlib=/usr/local/lib/zlib
  --without-http_browser_module
  --without-http_geo_module
  --without-http_limit_req_module
  --without-http_limit_conn_module
  --without-http_memcached_module
  --without-http_referer_module
  --without-http_split_clients_module
  --without-http_ssi_module
  --without-http_upstream_ip_hash_module
  --without-http_userid_module
  --without-http_uwsgi_module
  --add-module=/usr/local/include/nginx-upload-progress-module
  --add-module=/usr/local/include/nginx-upstream-fair
make
make install

Don't forget to clean up everything:

cd /usr/local
rm -rf
  src/nginx
  include/nginx-upload-progress-module
  include/nginx-upstream-fair
  lib/pcre
  lib/zlib
  lib/openssl

You'll now have a working nginx binary at /usr/sbin/nginx. Also make sure to update your init-script (at /etc/init.d/nginx) for nginx. Here's—as an example—my personal init-script:

https://github.com/Fleshgrinder/nginx/blob/master/nginx.sh

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.