# How to run multiple nginx master processes

**URL:** <https://www.ruby-forum.com/t/how-to-run-multiple-nginx-master-processes/198809>\
**Category:** NGINX\
**Created:** [November 8, 2010, 11:46am UTC](https://www.ruby-forum.com/t/how-to-run-multiple-nginx-master-processes/198809 "2010-11-08T11:46:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![okkezSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Post date:** [November 8, 2010, 11:46am UTC](https://www.ruby-forum.com/t/how-to-run-multiple-nginx-master-processes/198809/1 "2010-11-08T11:46:06Z")

</div>

I want to run multiple nginx master processes at boot time, based on  
this  
script [Ubuntu Upstart | NGINX](http://wiki.nginx.org/Nginx-init-ubuntu).

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

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin  
DAEMON=/usr/local/sbin/nginx

PS=“nginx”  
PIDNAME=“nginx” #lets you do $PS-slave  
PIDFILE=$PIDNAME.pid #pid file  
PIDSPATH=/var/run

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

lockfile=/var/lock/subsys/nginx  
NGINX\_CONF\_FILE=“/usr/local/nginx/conf/nginx.conf”

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  
binary  
PIDFILE=$PIDNAME.pid #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?

/vfclists

---

<div class="post-metadata">

**Author:** ![vfcforums](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/85e7bf/32.png) [@vfcforums](https://www.ruby-forum.com/u/vfcforums)\
**Post date:** [November 8, 2010, 3:01pm UTC](https://www.ruby-forum.com/t/how-to-run-multiple-nginx-master-processes/198809/2 "2010-11-08T15:01:35Z")

</div>

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

HTH  
Nuno

–  
Mars 2 Stay!

> **[Golden Hammer](https://xkcd.com/801/)**
>
> Took me five tries to find the right one, but I managed to salvage our night out--if not the boat--in the end.

/etc
