Saturday, August 30, 2008

Compiling Nginx on OS X Leopard in 5 minutes

I went to compile Nginx on my laptop this evening, and couldn't find a how-to for Leopard. Well at least not on the first page or 2 of search results.

Danger Weary Traveller!

I happen to be running OS X version 10.5.4 build 9E17.  

If you are running something different, these directions may fail.  In fact, for all I know your computer may actually blow-up.  Yes, as in burst into flames and melt into a smoldering heap of plastic mush.  Compiling stuff really is that scary.  Hide the children.  Don eye protection.
 
False Advertising Disclaimer
Whether it will really take you 5 minutes or not probably depends on your processor and whether or not your copy & paste skills are up to par.  But seriously, it took me longer to write this post than to do the actual install.

Related Sites
Official Nginx Site
Nginx Wiki
Official PCRE Site

Satisfy PCRE Dependency
Nginx requires PCRE to be installed.  PCRE stands for Prank Calling Really is Evil, or something like that.  But whatever it is, Nginx thinks it just can't live without it.

$ sudo mkdir -p /usr/local/src
$ cd /usr/local/src
$ curl -O ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.7.tar.gz
$ tar xvfz pcre-7.7.tar.gz
$ cd pcre-7.7
$ ./configure --prefix=/usr/local
$ make
$ sudo make install
$ cd ..

Install Nginx
$ curl -O http://sysoev.ru/nginx/nginx-0.6.32.tar.gz
$ tar xvfz nginx-0.6.32.tar.gz
$ cd nginx-0.6.32
$ ./configure --prefix=/usr/local --with-http_ssl_module
$ make
$ sudo make install

Now if you ask:

$ which nginx

You should receive the answer /usr/local/sbin/nginx

If not, you probably need to add /usr/local to your PATH.

Nginx will setup a default index.html file in /usr/local/html. The default nginx.conf file will be in /usr/local/conf and will be set to serve this index.html file. To start Nginx:

$ sudo nginx

And finally, to see the fruits of your labors open your favorite browser and navigate to http://localhost

Next you get to configure Nginx to serve up whatever it is you want to serve. But that search query will already provide you with many, many results...

1 comment:

  1. Took me 14 minutes, but fantastic nonetheless.

    Thanks for posting this.

    ReplyDelete