Skip to content

Instantly share code, notes, and snippets.

@philiparthurmoore
Forked from Globegitter/nginx-latest.sh
Created October 26, 2015 03:11
Show Gist options
  • Save philiparthurmoore/3bff87ddfd2a267fa728 to your computer and use it in GitHub Desktop.
Save philiparthurmoore/3bff87ddfd2a267fa728 to your computer and use it in GitHub Desktop.
Install the latest nginx from source for Ubuntu 14.04
#Possibly easier but untested method:
wget -O - http://nginx.org/keys/nginx_signing.key | sudo apt-key add -
#Now open ` /etc/apt/sources.list ` and add following repositories at the end
deb http://nginx.org/packages/ubuntu/ trusty nginx
deb-src http://nginx.org/packages/ubuntu/ trusty nginx
## Tested method to install the latest version of nginx ##
#Install the PCRE library needed by nginx
sudo apt-get install libpcre3 libpcre3-dev
#Replace by the latest version number found on http://nginx.org/
wget http://nginx.org/download/nginx-1.7.4.tar.gz
tar -xvf nginx-1.7.4.tar.gz
cd nginx-1.7.4
#These flags make sure to put nginx somewhere that is usuall in PATH and to activate the https module
./configure --sbin-path=/usr/local/sbin --with-http_ssl_module
make
sudo make install
# Download nginx startup script
wget -O init-deb.sh http://library.linode.com/assets/660-init-deb.sh
# Move the script to the init.d directory & make executable
sudo mv init-deb.sh /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx
# Add nginx to the system startup
sudo /usr/sbin/update-rc.d -f nginx defaults
## Make sure to add the nginx.conf into /etc/init/nginx.conf
#This will make sure you get the following commands
#sudo service nginx start
#sudo service nginx stop
#sudo service nginx restart
#sudo service nginx status
#nginx
description "nginx http daemon"
author "Philipp Klose <me@'thisdomain'.de>"
start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]
env DAEMON=/usr/local/sbin/nginx
env PID=/usr/local/nginx/logs/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