Skip to content

Instantly share code, notes, and snippets.

@beatfactor
Last active February 6, 2025 14:20
Show Gist options
  • Save beatfactor/a093e872824f770a2a0174345cacf171 to your computer and use it in GitHub Desktop.
Save beatfactor/a093e872824f770a2a0174345cacf171 to your computer and use it in GitHub Desktop.
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 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, and also for regular expressions support in the location directive.

$ 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.

$ 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 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:

$ 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

$ [sudo] make && make install

Add the nginx binary to $PATH:

export PATH="/usr/local/nginx/sbin:$PATH"
@kubada
Copy link

kubada commented Jan 1, 2025

cd macPro/usr/local

manually created the src, nginx folders

curl -OL https://nginx.org/download/nginx-1.26.2.tar.gz
tar -xvzf nginx-1.26.2.tar.gz && rm nginx-1.26.2.tar.gz  
cd nginx-1.26.2/
curl -OL https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.44/pcre2-10.44.tar.gz
tar -xvzf pcre2-10.44.tar.gz && rm pcre2-10.44.tar.gz   
curl -OL https://github.com/openssl/openssl/releases/download/openssl-3.4.0/openssl-3.4.0.tar.gz
tar -xvzf openssl-3.4.0.tar.gz && rm openssl-3.4.0.tar.gz   
./configure --with-pcre=../pcre2-10.44/ --with-openssl=../openssl-3.4.0/
sudo make && make install 
export PATH="/usr/local/nginx/sbin:$PATH"
cd /macPro/usr/local/nginx/sbin
nginx

http://localhost:80 >> Welcome to nginx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment