Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RaviTezu/374dd31cc9f6a921f215 to your computer and use it in GitHub Desktop.
Save RaviTezu/374dd31cc9f6a921f215 to your computer and use it in GitHub Desktop.
Compile nginx from source, include the Headers More module - Ubuntu
sudo su -
# stuff we need to build from source
apt-get install libpcre3-dev build-essential libssl-dev
# get the nginx source
cd /opt/
wget http://nginx.org/download/nginx-0.8.54.tar.gz
tar -zxvf nginx*
# we'll put the source for nginx modules in here
mkdir /opt/nginxmodules
cd /opt/nginxmodules
# get the source for the Headers More module - see http://wiki.nginx.org/HttpHeadersMoreModule
wget --no-check-certificate http://github.com/agentzh/headers-more-nginx-module/tarball/v0.14
tar -zxvf v0.14
mv agentzh-headers-more-nginx-module-2cbbc15 headers-more
cd /opt/nginx*/
# configure with chosen modules - see http://wiki.nginx.org/InstallOptions & http://articles.slicehost.com/2008/5/13/ubuntu-hardy-installing-nginx-from-source
./configure \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--http-log-path=/var/log/nginx/access.log \
--with-http_dav_module \
--http-client-body-temp-path=/var/lib/nginx/body \
--http-proxy-temp-path=/var/lib/nginx/proxy \
--with-http_stub_status_module \
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
--with-debug \
--with-http_ssl_module \
--with-pcre \
--with-ipv6
make
make install
vi /etc/init.d/nginx # edit the DEAMON with the correct new path, which is now /usr/local/nginx/sbin/nginx
/etc/init.d/nginx start
# Nginx should now be running - test it by visting your http://hostname/
@RaviTezu
Copy link
Author

/etc/init/nginx.conf:

# nginx

description "nginx http daemon"
author "George Shammas <[email protected]>"

start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]

env DAEMON=/usr/local/nginx/sbin/nginx
env PID=/var/run/nginx.pid

expect fork
respawn
respawn limit 10 5
#oom never

pre-start script
        $DAEMON -t
        if [ $? -ne 0 ]
                then exit $?
        fi
end script

exec $DAEMON

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment