Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Tried and true Nginx init script - got enhancements? Send a pull!

branch: master

Merge pull request #12 from sturgill/master

Doc and script changes
- Modify to load `/etc/nginx/default` prior to testing `$DAEMON` @sturgill
- Update default location in docs @sturgill
latest commit b584194006
Jason Giedymin authored
Octocat-spinner-32 .gitignore Update README February 10, 2014
Octocat-spinner-32 Correct location of default folder in docs April 10, 2014
Octocat-spinner-32 Vagrantfile Tests January 31, 2014
Octocat-spinner-32 Update changelog January 31, 2014
Octocat-spinner-32 deploy-nginx.yml Clean deploy February 05, 2014
Octocat-spinner-32 integration-tests.yml Tests January 31, 2014
Octocat-spinner-32 inventory.yml Add testing framework January 30, 2014
Octocat-spinner-32 nginx Load /etc/nginx/default before testing $DAEMON April 10, 2014


Tried and true Nginx init script.

Author: Jason Giedymin

Check out my other repos!


Rest assured that this repo will be maintained indefinitely beyond Ubuntu LTS and systemd adoption into Ubuntu stable.

Last tested with:

  1. Ubuntu 12.xx & 13.xx
  2. nginx-1.5.9 - should also work with 1.6.xx series, just haven't tested it yet.


It is recommended to install Nginx by doing a full compile & build. Not all package repositories keep their branches updated. For security it is your duty to maintain a good working environment and thus includes all interfacing applications. This script works turn-key with the default compile of nginx. It is fully recommended that you go through the variables contained within this script if you have a custom compiled build.

A great resource is the Nginx Wiki.

Basic Install

Basic install instructions, use sudo if necessary for the below (depends on your setup/security).

# [optional as you may have these installed]
sudo apt-get install libpcre3-dev zlib1g-dev

mkdir -p ~/temp/nginx-install
cd ~/temp/nginx-install

# download/curl/wget nginx 
tar -xvf nginx-1.5.9.tar.gz
cd nginx-1.5.9/
sudo make install

#copy/download/curl/wget the init script
sudo wget -O /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx

service nginx status  # to poll for current status
service nginx stop    # to stop any servers if any
service nginx start   # to start the server

sudo update-rc.d -f nginx defaults

#[optional remove the upstart script]
sudo update-rc.d -f nginx remove

Advanced Configuration

If you need to override the values within the script you should use /etc/default/nginx.

You can override any of these values:

  • PATH
  • PS
  • lockfile

For instance, if you needed to change the description of the server during logging:

# Edit [/etc/default/nginx] and add the below line
DESCRIPTION="My Awesome Nginx Server..."

# Next run the below command:
sudo service nginx restart

# Output of running restart with nginx defaults file:
* Stopping My Super Nginx Server...                                  [ OK ] 
* Starting My Super Nginx Server...                                  [ OK ]

# Notice that is says "My Super Nginx Server..." as opposed to the default
# "Nginx Server...".


Tests run as part of the deployment scripts integration-tests.yml.

To start make sure you have vagrant, and ansible installed.

Download the Ubuntu base box:

vagrant box add

Run vagrant:

vagrant up

Manually provision again:

vagrant provision


Contributions are welcome!

Something went wrong with that request. Please try again.