# Install Nginx on Mac OS from source _no Homebrew required_ ## 1. Download Nginx ```bash $ cd /usr/local/src $ curl -OL http://nginx.org/download/nginx-1.12.2.tar.gz $ 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](http://nginx.org/en/docs/http/ngx_http_rewrite_module.html), and also for regular expressions support in the location directive. ```bash $ curl -OL https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz $ tar xvzf pcre-8.41.tar.gz && rm pcre-8.41.tar.gz ``` ## 3. Configure Nginx See the full list of `./configure` options: http://nginx.org/en/docs/configure.html. ```sh $ cd nginx-1.12.2/ ``` ### Compile nginx without SSL support ```bash $ ./configure --with-pcre=../pcre-8.41/ ``` ### with SSL support Download OpenSSL sources and extract: ```bash $ curl -OL https://www.openssl.org/source/openssl-1.1.0.tar.gz $ tar xvzf openssl-1.1.0.tar.gz && rm openssl-1.1.0.tar.gz ``` Compile Nginx: ```sh $ cd ../nginx-1.12.2/ $ ./configure --with-pcre=../pcre-8.41/ --with-http_ssl_module --with-openssl=/usr/local/src/openssl-1.1.0 ``` ## 4. Install Nginx ```bash $ [sudo] make && make install ``` Add the nginx binary to `$PATH`: ```bash export PATH="/usr/local/nginx/sbin:$PATH" ```