Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Install Nginx on Mac OS from source (without brew)

Install Nginx on Mac OS from source

no Homebrew required

1. Download Nginx

$ cd /usr/local/src
$ curl -OL
$ tar -xvzf nginx-1.12.2.tar.gz && rm nginx-1.12.2.tar.gz

2. Download the PCRE library

The PCRE library distribution (version 4.4 — 8.41) needs to be downloaded from the PCRE site and extracted. The rest is done by nginx’s ./configure and make. PCRE is required for the http_rewrite_module, and also for regular expressions support in the location directive.

$ curl -OL
$ tar xvzf pcre-8.41.tar.gz && rm pcre-8.41.tar.gz

3. Configure Nginx

See the full list of ./configure options:

$ cd nginx-1.12.2/

Compile nginx without SSL support

$ ./configure --with-pcre=../pcre-8.41/ 

with SSL support

Download OpenSSL sources and extract:

$ curl -OL
$ tar xvzf openssl-1.1.0g.tar.gz && rm openssl-1.1.0g.tar.gz 

Compile Nginx:

$ cd ../nginx-1.12.2/
$ ./configure --with-pcre=../pcre-8.41/ --with-http_ssl_module --with-openssl=/usr/local/src/openssl-1.1.0g

4. Install Nginx

$ [sudo] make && make install

Add the nginx binary to $PATH:

export PATH="/usr/local/nginx/sbin:$PATH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment