Guide on switching from distro-provided nginx to nginx built from source?
steve at greengecko.co.nz
Thu Mar 13 22:02:03 UTC 2014
On Thu, 2014-03-13 at 15:34 -0400, Jeff Kaufman wrote:
> I haven't been able to find a good guide for people who have been
> using nginx as installed by their linux distribution who want to
> switch to using an nginx they built themselves. This comes up a lot
> with ngx_pagespeed because for many users we're the first module they
> want which isn't packaged with their distro. Does this guide exist?
> If not, I might write one for ubuntu at least.
> This is somewhat similar to a regular "install nginx from source"
> guide but it needs to have at least:
> * how to get a list of the modules you need to add (nginx -V | grep
> * 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
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
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...
gpg --keyserver pgpkeys.mit.edu --recv-key A1C052F
Code downloaded and verified.
expand the archive and move into it
tar xf nginx-1.5.11.tar.gz
To get the current configuration, use the command
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
--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
until it completes correctly.
then you can run
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 ).
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.
Steve Holdoway BSc(Hons) MIITP
More information about the nginx