Nginx on Mac OS X Snow Leopard in 2 Minutes

byKevin WorthingtononFebruary 24, 2010

Overview
This is a quick article to show you how I compiled a basic version of Nginx 0.8.33 on Mac OS X 10.6.2 Snow Leopard. The “2 minute” compilation that I mention in the title of this article is when using the script that I provide below. For the Do-It-Yourself (DIY) crowd, I’m breaking down the steps. Variations in your Mac’s specs, and your copy and paste skills may increase the total time to over 2 minutes.

Prerequisites
First, if you do not already have it installed, download Xcode from Apple’s website, and run the installer from the .dmg file. For the record, the file I installed was called xcode321_10m2003_developerdvd.dmg, yours may be slightly different.

Install Nginx
(You should still be in /usr/local/src, if you followed along from above.)tar xvzf nginx-0.8.33.tar.gzcd nginx-0.8.33./configure --prefix=/usr/local --with-http_ssl_modulemakesudo make install

Start Nginx
Assuming that you have /usr/local in your $PATH (which nginx should say:/usr/local/sbin/nginx), you can simply run:sudo nginx
Note: to add /usr/local to your $PATH variable, edit or create ~/.profile to include it. For reference, mine currently looks like this:PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local:/usr/local/sbin:/usr/local/bin:/usr/X11/bin:/opt/X11/bin" – I emphasized in bold type what you need to add to your PATH.

The 2 Minute way, using my script
All of the above instructions, in a nice little script. Save it to your Mac as build-nginx.sh, and run:chmod a+x build-nginx.shsudo ./build-nginx.sh

Conclusion
It’s a pretty quick process to get Nginx installed nicely on your Mac, especially if you use my script. This provides a very basic install, but it should get you moving in the right directions. If you have any comments, questions, or suggestions, I would love to hear your feedback, so leave a comment below.