Friday, August 16, 2013

Installing Nginx on Mac OS X

In this guide I want to show how to install Nginx server on Mac OS X.

Prerequisites
  1. In order to be able to compile source code you will need Xcode with Command Line Tools installed. If you already have Xcode installed check if Command Line Tools installed: Xcode -> Preferences -> Download.
  2. Nginx requires PCRE (Perl Compatible Regular Expressions). We only need source code, because we'll be doing static compilation in this guide. The source can be downloaded here: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
  3. Nginx sources can be downloaded here: http://nginx.org/en/download.html


Installation

Installation steps:
  1. Extract PCRE and Nginx archives in temp folder. You wil have 2 folders, e.g.: prce-8.33 and nginx-1.4.2
  2. Go to nginx-1.4.2 and run following commands:
    $ ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-pcre=../pcre-8.33
    $ make
    $ sudo make install
  3. After those commands Nginx will be installed into /usr/local/nginx
To start Nginx run the following command:

$ /usr/local/nginx/sbin/nginx

Now open your browser and goto http://localhost. If you see Nginx welcome page.

Detailed information about server configuration can be found here: http://nginx.org/