Install Nginx in MAC

Run the brew install nginx command to install Nginx:

brew install nginx

Restart nginx:

brew services restart nginx


Stopping `nginx`... (might take a while)
==> Successfully stopped `nginx` (label: homebrew.mxcl.nginx)
==> Successfully started `nginx` (label: homebrew.mxcl.nginx)

Nginx will be installed at the following location: /opt/homebrew/Cellar/nginx

/opt/homebrew/Cellar/nginx/1.21.6_1 is the path in the above example where Nginx is installed.

Docroot is: /opt/homebrew/var/www

Run the following command to test whether Nginx is installed properly:

curl HTTP://localhost:8080

That command will give you the following output:

<!DOCTYPE html>
<title>Welcome to nginx!</title>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;

You can access the same in browser itself for the response check from nginx:

That page is being served by the following page: /opt/homebrew/var/www/index.html