Welcome! Log In Create A New Profile

Advanced

Re: Guide on switching from distro-provided nginx to nginx built from source?

March 13, 2014 06:04PM
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
> 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 Holdoway BSc(Hons) MIITP
http://www.greengecko.co.nz
Linkedin: http://www.linkedin.com/in/steveholdoway
Skype: sholdowa

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Guide on switching from distro-provided nginx to nginx built from source?

Jeff Kaufman March 13, 2014 03:36PM

Re: Guide on switching from distro-provided nginx to nginx built from source?

GreenGecko March 13, 2014 06:04PM

Re: Guide on switching from distro-provided nginx to nginx built from source?

B.R. March 13, 2014 07:08PM

Re: Guide on switching from distro-provided nginx to nginx built from source?

George March 13, 2014 07:58PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 324
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready