How to run multiple nginx master processes

I want to run multiple nginx master processes at boot time, based on
script Ubuntu Upstart | NGINX.

There are some variables at the top and I’d like to know if changing
variables will make it successful.


PIDNAME=“nginx” #lets you do $PS-slave
PIDFILE=$ #pid file

DESCRIPTION=“Nginx Server…”

RUNAS=root #user to run as

SCRIPT_OK=0 #ala error codes
SCRIPT_ERROR=1 #ala error codes
TRUE=1 #boolean
FALSE=0 #boolean


Of these the most likely ones are

PS=“nginx” #own comment - it is used to
reference the running process in killall etc
# I wonder if symlinking the
nginx binary and using that will stop the code
# from breaking
# it appears to be used for
locating the running process, and I suspect if it is not
#changed it will interfere
with the default proces
# hopefully nginx daemon does
use hardcoded references to its own name for
# process management

PIDNAME=“nginx” #own comment - obvious need to avoid default
PIDFILE=$ #own comment - changed by
changing PIDNAME

PIDSPATH=/var/run # own comment - no need

DESCRIPTION=“Nginx Server…” # own comment - can be
changed, but looks harmless

RUNAS=root # own comment - this can be
changed for a particular user

SCRIPT_OK=0 #own comment - no need - ala
error codes
SCRIPT_ERROR=1 #own comment - no need - ala
error codes
TRUE=1 #own comment - no need - boolean
FALSE=0 #own comment - no need - boolean

lockfile=/var/lock/subsys/nginx #own comment = has to be
different from default process
NGINX_CONF_FILE=“/usr/local/nginx/conf/nginx.conf” #own comment -
clearly needs to be different

Any opinions, has anyone tried it before?


It seems to be more OS-specific than nginx-specific, have you asked in
the Ubuntu forums? Why would you want to run two masters?!

Unless nginx does a check to see if another nginx is running (by .pid
file?, so at least that you’d have to change in the script), i guess
you should be safe using two different server configuration files
(i.e. different listening ports and domains).


Mars 2 Stay!