Restarting Nginx On Mac Development

2,837 views
Skip to first unread message

Brian Armstrong

unread,
May 19, 2009, 5:05:17 PM5/19/09
to Phusion Passenger Discussions
This may be a silly question, but there doesn't seem to be a start/
stop/restart command for nginx on Mac?

Following the screencast I see it was started with "sudo /opt/nginx/
sbin/nginx"

Do I just run this command to restart it after making changes to
nginx.conf?

Thanks!
Brian

Christopher Bailey

unread,
May 19, 2009, 5:33:45 PM5/19/09
to phusion-...@googlegroups.com
I just set up aliases, and use the PID file, such as:

alias startnginx='sudo /opt/nginx/sbin/nginx'
alias stopnginx='sudo kill `cat /opt/nginx/logs/nginx.pid `'
alias restartnginx='stopnginx; startnginx'
--
Christopher Bailey
Cobalt Edge LLC
http://cobaltedge.com

W. Andrew Loe III

unread,
May 20, 2009, 1:33:30 AM5/20/09
to phusion-...@googlegroups.com
Macports has some handy plists for using loadctl, I just piggy back
off those. Just make sure you set daemon off; in your nginx.conf since
daemondo wraps the nginx process as a daemon.

# nginx short cuts
alias start_nginx='sudo launchctl load -w
/Library/LaunchDaemons/org.macports.nginx.plist'
alias stop_nginx='sudo launchctl unload -w
/Library/LaunchDaemons/org.macports.nginx.plist'
alias restart_nginx='sudo launchctl unload -w
/Library/LaunchDaemons/org.macports.nginx.plist; sudo launchctl load
-w /Library/LaunchDaemons/org.macports.nginx.plist'

This handily makes nginx persistently on(or off) across restarts.

Brian Armstrong

unread,
May 20, 2009, 12:10:07 PM5/20/09
to Phusion Passenger Discussions
Nice work Christopher and Andrew, thanks for sharing it. I'm
surprised this is what it comes down to, but it works.

Andrew, one thing I was wondering about...is passenger still using the
macports nginx? It seemed like it installed a new one so I wasn't
sure.

On May 20, 2:33 am, "W. Andrew Loe III" <and...@andrewloe.com> wrote:
> Macports has some handy plists for using loadctl, I just piggy back
> off those. Just make sure you set daemon off; in your nginx.conf since
> daemondo wraps the nginx process as a daemon.
>
> # nginx short cuts
> alias start_nginx='sudo launchctl load -w
> /Library/LaunchDaemons/org.macports.nginx.plist'
> alias stop_nginx='sudo launchctl unload -w
> /Library/LaunchDaemons/org.macports.nginx.plist'
> alias restart_nginx='sudo launchctl unload -w
> /Library/LaunchDaemons/org.macports.nginx.plist; sudo launchctl load
> -w /Library/LaunchDaemons/org.macports.nginx.plist'
>
> This handily makes nginx persistently on(or off) across restarts.
>
> On Tue, May 19, 2009 at 2:33 PM, Christopher Bailey
>
> <ch...@cobaltedge.com> wrote:
> > I just set up aliases, and use the PID file, such as:
> > alias startnginx='sudo /opt/nginx/sbin/nginx'
> > alias stopnginx='sudo kill `cat /opt/nginx/logs/nginx.pid `'
> > alias restartnginx='stopnginx; startnginx'
> > On Tue, May 19, 2009 at 2:05 PM, Brian Armstrong <barmstr...@gmail.com>

Hongli Lai

unread,
May 20, 2009, 12:18:16 PM5/20/09
to phusion-...@googlegroups.com
On Wed, May 20, 2009 at 6:10 PM, Brian Armstrong <barms...@gmail.com> wrote:
>
> Nice work Christopher and Andrew, thanks for sharing it.  I'm
> surprised this is what it comes down to, but it works.
>
> Andrew, one thing I was wondering about...is passenger still using the
> macports nginx?  It seemed like it installed a new one so I wasn't
> sure.

No, the Passenger installer downloads the official Nginx tarball and
compiles and installs that for you. If you want to use MacPorts's
Nginx then you must somehow find a way to extract MacPorts's Nginx
source tarball, and run the Passenger installer and tell it to use the
extracted Nginx source directory.

--
Phusion | The Computer Science Company

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)

W. Andrew Loe III

unread,
May 20, 2009, 1:30:06 PM5/20/09
to phusion-...@googlegroups.com
I have a Macports Portfile for nginx 0.6.36 + passenger + Valery
Kholodkov's upload module. I'll attach it.

There is a ticket open on the Macports trac, hopefully it will get
accepted soon.
https://trac.macports.org/ticket/19342

With this portfile you can just do:
$ port install nginx +passenger

I use:
$ port install nginx +ssl +passenger +upload

I have Ruby EE in /opt/ree and use macports ruby186 to facilitate
swapping, I'm working on a port of 1.8.6 with all the MBARI and Rails
Bench patches, I think we may be moving that way in production soon.
Portfile
Reply all
Reply to author
Forward
0 new messages