On Thu, 2014-03-13 at 15:34 -0400, Jeff Kaufman wrote:
- how to get a list of the modules you need to add (nginx -V | grep
configure_arguments)
- how to copy your config over
- how to keep and modify your nginx init script when uninstalling the
distro-provided nginx
- how to do all of this with minimal downtime and risk on a single VPS
Jeff
A good starting point is to build it up using the current configuration
delivered from your distro. That way you don’t need to fool around
moving config files, etc and a reinstall is just to copy /usr/sbin/nginx
into place.
You need a dev environment…
apt-get install build-essential or yum groupinstall “Development Tools”
You’ll need a load of dependencies, so expect to run the configure quite
a few times before it succeeds!
And the source code…
cd /usr/local/src
wget http://nginx.org/download/nginx-1.5.11.tar.gz
wget http://nginx.org/download/nginx-1.5.11.tar.gz.asc
gpg --keyserver pgpkeys.mit.edu --recv-key A1C052F
gpg nginx-1.5.11.tar.gz.asc
Code downloaded and verified.
expand the archive and move into it
tar xf nginx-1.5.11.tar.gz
cd nginx-1.5.11
To get the current configuration, use the command
nginx -V
I use the output to generate a file build.sh which I then modify ready
to run the configure ( this is on ans amazon ec2 server )…
$ cat build.sh
./configure
–prefix=/etc/nginx
–sbin-path=/usr/sbin/nginx
–conf-path=/etc/nginx/nginx.conf
–error-log-path=/var/log/nginx/error.log
–http-log-path=/var/log/nginx/access.log
–pid-path=/var/run/nginx.pid
–lock-path=/var/run/nginx.lock
–http-client-body-temp-path=/var/cache/nginx/client_temp
–http-proxy-temp-path=/var/cache/nginx/proxy_temp
–http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp
–http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
–http-scgi-temp-path=/var/cache/nginx/scgi_temp
–user=nginx
–group=nginx
–with-http_ssl_module
–with-http_realip_module
–with-http_addition_module
–with-http_sub_module
–with-http_dav_module
–with-http_flv_module
–with-http_mp4_module
–with-http_gunzip_module
–with-http_gzip_static_module
–with-http_random_index_module
–with-http_secure_link_module
–with-http_stub_status_module
–with-mail
–with-mail_ssl_module
–with-file-aio
–with-ipv6
–with-cc-opt=‘-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic’
so I can keep on running
sh build.sh
until it completes correctly.
then you can run
make
make install
nginx -t
and if that is successful, restart nginx to get it running. Make sure
you’ve saved the old version of nginx first, although both rpm and dpkg
offer options to reinstall if necessary.
You can also use this as a starting point to build in ngx_pagespeed
support for example ( good howtos online ).
I also
strip /usr/sbin/nginx
to drop the debug info. It’s way more important to do this if using the
aforementioned extension, as IIRC the end result is over 100MB.
hth,
Steve
–
Steve H. BSc(Hons) MIITP
Linkedin: http://www.linkedin.com/in/steveholdoway
Skype: sholdowa