There are following steps to install the Nginx on Mac OS:
How to Install Nginx on MacOS Introduction. Nginx is a web server which can also be used as a HTTP cache, load balancer and reverse proxy.This was first created by Igor Sysoev and released in 2004 under the terms of BSD like license. In this tutorial, we will learn the steps involved in the installation of Nginx. I'm using nginx on OS X 10.8. Freshly installed nginx but can't find a way to restart nginx except kill nginxpid say kill 64116. Wondering if there are better ways to restart nginx. Found some methods on Google and SO but didn't work: nginx -s restart sudo fuser -k 80/tcp; sudo /etc/init.d/nginx restart.
Step 1: Download Homebrew
启动 nginx 也可以使用下面的命令启动,但是配置文件nginx.conf修改后用这个命令执行不生. Mac OS上搭建LNMP开发环境. The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that nginx can run without sudo. Nginx will load all files in /usr/local/etc/nginx/servers/. To have launchd start nginx now and restart at login: brew services start nginx Or, if you don't want/need a background service you can just run: nginx Summary 🍺 /usr/local/Cellar/nginx/1.10.1: 7 files, 972.3K.
To install the Nginx on Mac OS, Homebrew must be installed on the system. Homebrew is a package manager for Mac operating system that allows us to install various Unix applications easily. If you don't have Homebrew, use the following link to install: https://brew.sh/
Or simply type the following command on the terminal:
Step 2: Update the Homebrew repository index
Update the repository index of the Homebrew package installer. This can be done through the brew update command.
Step 3: Install Nginx
The homebrew package installer will help to install the Nginx web server on the macOS. To install the Nginx, use the following command:
The Nginx server will install on the location /usr/local/cellar. The entire executable services related to starting and stopping Nginx are stored inside the bin folder of the installation directory.
Nginx For Mac
The web server will listen by default on port number 8080. To start the Nginx, use the following command:
Nginx Mac Os Php
And to check whether the nginx is correctly installed on the computer, type the localhost on the browser or run the following command on the console:
To stop the Nginx services, use the following command:
Important locations:
- Add configs in -> /usr/local/etc/nginx/servers/
- Default config -> /usr/local/etc/nginx/nginx.conf
- Logs will be in -> /usr/local/var/log/nginx/
- Default webroot is -> /usr/local/var/www/
- Default listen address -> http://localhost:8080
Heavily borrowed from: Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.
Install nginx
For enabling a site:
Start nginx:

Update /etc/hosts
file:
My site config file:
My nginx.conf

UPDATES:
Despite following the above instructions, I was again caught with error issues while setting up my new Catalina OS.
The resolution steps after troubleshooting the problems were:
Mac Nginx Config
Make sure the last line in the above nginx.conf
is updated to:
Note ... then *.*

Next, this was a REAL issue, I did everything perfectly but STILL the enabled was not getting picked up!!!

As mentioned here (https://stackoverflow.com/a/53528685), I needed to add listen [::]:80;
to bind the site to IPv6 and my PC was on an IPv6 connection
Mac Nginx Php
Below is the exact site config:
Mac Nginx Stop
Also, not to forget .. my /etc/hosts/
file is:

Comments are closed.