Skip to content

Instantly share code, notes, and snippets.

Last active May 7, 2022 18:19
Show Gist options
  • Save Globegitter/685e3739c0f181bda3ec to your computer and use it in GitHub Desktop.
Save Globegitter/685e3739c0f181bda3ec to your computer and use it in GitHub Desktop.
Install the latest nginx from source for Ubuntu 14.04
# Automatically instal the latest nginx
wget -O - | sudo apt-key add -
#Make a backup copy of your current sources.list file
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
#Now copy the following repositories to the end of ` /etc/apt/sources.list`
echo "deb trusty nginx" | sudo tee -a /etc/apt/sources.list
echo "deb-src trusty nginx" | sudo tee -a /etc/apt/sources.list
#If you want to use the 'stable' branch take:
#echo "deb trusty nginx" | sudo tee -a /etc/apt/sources.list
#echo "deb-src trusty nginx" | sudo tee -a /etc/apt/sources.list
#update to get the new repository
sudo apt-get update
sudo apt-get install nginx
## Longer way ##
## Manually build and install the latest nginx ##
#Install the PCRE library needed by nginx
sudo apt-get install libpcre3 libpcre3-dev
#Replace by the latest version number found on
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
sudo make install
# Download nginx startup script
wget -O
# Move the script to the init.d directory & make executable
sudo mv /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
# This automatically adds the nginx.conf from below into /etc/init/nginx.conf
# If something doesn't work, just copy it manually
sudo wget -O /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
##Now you can modify your nginx.conf in /usr/local/nginx/conf
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/
expect fork
respawn limit 10 5
#oom never
pre-start script
if [ $? -ne 0 ]
then exit $?
end script
exec $DAEMON
Copy link

gdbtek commented Aug 28, 2015

Copy link

it works! thank you very much

Copy link

anvodev commented Jul 27, 2016

thanks very much!

Copy link

thanks a lot !

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