• Stars
    star
    522
  • Rank 84,811 (Top 2 %)
  • Language
    Shell
  • Created over 14 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

nginx-init-ubuntu

Status

Build Status

Current release: v3.9.0

Previous stable release v3.8.0

Notes: v3.8.0 has been stable for the last several months without issues. v3.9.0 while stable, is new.

Info

Tried and true Nginx init script.

Ubuntu, Vagrant, and Docker tested!

You may also want to use the AnsibleShipyard ansible-nginx playbook.

Simple ansible playbook sits in this repository.

Author: Jason Giedymin <jasong -at- apache -=dot=- org>

Check out my other repos!

Support

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

Last tested with:

  1. Ubuntu 14.xx (works with prior versions)
  2. nginx-1.7.9 (works with prior versions)

Notes

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 
wget http://nginx.org/download/nginx-1.7.9.tar.gz
tar -xvf nginx-1.7.9.tar.gz
cd nginx-1.7.9/
./configure
make
sudo make install

#copy/download/curl/wget the init script
sudo wget https://raw.githubusercontent.com/JasonGiedymin/nginx-init-ubuntu/master/nginx -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

#[optional] 
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:

Variable Function
PATH Path environment variable
NGINXPATH Root path where installed
DAEMON Path to Deamon binary
PS Process name
PIDNAME Lets you do $PS-slave
PIDFILE Pid file
PIDSPATH Default PID location
DESCRIPTION Process description
RUNAS User to run as
NGINX_CONF_FILE Config file path

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...".

The NGINXPATH value should point to your installation of Nginx, the default is /usr/local/nginx

It's likely you'll need to update the NGINXPATH value if you didn't install from source. Eg, if you install Nginx using apt-get on Ubuntu nginx will be installed to /etc/nginx

# Changing NGINXPATH when Nginx was installed with apt-get
NGINXPATH=/etc/nginx

Testing

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 ubuntu-14.10 https://cloud-images.ubuntu.com/vagrant/utopic/current/utopic-server-cloudimg-amd64-vagrant-disk1.box

Run vagrant:

vagrant up

Manually provision again:

vagrant provision

Using with Docker

A basic Dockerfile will arrive shortly for testing, but note that I focued my efforts on creating an nginx ansible role. This repo has a Dockerfile which will install Nginx along with nginx-init-ubuntu (this repo) using ansible. Until the basic testing Dockerfile is in place here please refer to the ansible role and it's Dockerfile -- if your looking for stability.

If your looking for a more production and developer friendly Dockerfile, look here.

When using the ansible role mentioned above you will need to set nginx_docker_override to True as the role will detect if running within a Dockerfile. This is to prevent nginx running in daemon mode.

A copy of nginx-init-ubuntu is present in the ansible role.

Contributions

Contributions are welcome!

More Repositories

1

backbone-todojs-coffeescript

The Backbone todos.js in CoffeeScript
JavaScript
73
star
2

express-messages-bootstrap

Twitter Bootstrap and Facebook fBootstrap compatible Express Messages
JavaScript
58
star
3

docker-cassandra-cluster

Basic cluster script for cassandra using docker.
Shell
23
star
4

Flask-Module-Scaffold

A simple scaffold / template for Flask modules (aka sub apps)
Python
13
star
5

FluidSim

Fluid Simulation
GLSL
4
star
6

essentialjsdesignpatterns-with-coffeescript

Essential JS Design Patters with CoffeeScript
JavaScript
4
star
7

sd-webui

sd-webui
Python
3
star
8

Android-App-Inventor

Android App Inventor
3
star
9

CDN-Rewrites-Redux

URL Rewriter for Wordpress
PHP
3
star
10

cgol

CGOL is a Coffeescript implementation of Conway's Game of Life by Jason Giedymin.
CoffeeScript
3
star
11

ats-docker

Apache TrafficServer Dockerfiles
Shell
2
star
12

Pyramid-Scripts

Scripts for Pyramid - Test Bed
Python
2
star
13

cdn-off-linker-redux

Redux of the content distribution plugin by ossdl.de for wordpress/mu.
PHP
2
star
14

pi-node

Performant Chudnovsky Pi on NodeJS
JavaScript
2
star
15

node-rrbench

Node Request Response Bench
JavaScript
1
star
16

SimpleScalaUtil

Simple Scala Util Lib
Scala
1
star
17

collective-cookbooks

cookbooks yo!
Ruby
1
star
18

terraform-docker

Terraform Dockerfile
Shell
1
star
19

ansible-var-test

ansible-var-test
1
star
20

Raphlash

Animation experiment with Raphaeljs.
JavaScript
1
star
21

HN-Viewer

Yet another HN viewer.
1
star
22

Holobot

Early experiment of vm automation
Ruby
1
star
23

chef-mesos

chef-mesos
Ruby
1
star
24

libretro-nvidia-jetson

Libretro Scripts & Compiled Cores for the Nvidia Jetson TX1/2
Makefile
1
star
25

chef-marathon

Marathon Chef Cookbook
Ruby
1
star
26

StreamerExperiment

Experimenting with Scala parallel collections, Java Fork Join, and Akka Actors for general computing
Scala
1
star
27

collective

The new collective
Ruby
1
star
28

SPLogger

Simple Python Logger
Python
1
star
29

ansible-base

Base Ansible Dockerfiles
Shell
1
star
30

JasonGiedymin

Particle Cloud - Jason Giedymin's HomePage - 2012+
JavaScript
1
star
31

basic-app-db-template

A basic app db template
Shell
1
star
32

py-service-os

Python Services and Service Manager Experiment
Python
1
star
33

vhost-backer

Backs up your virtual host and simple host sites along with the attached WordPress database.
Shell
1
star
34

Solarized-IDE-Themes

Themes for Eclipse, IntelliJ, and Sublime Text 2
Shell
1
star