Installing nginx in macOS Ventura using homebrew

Ram
1 min readAug 23, 2023
NGINX

Install with home brew using below command

brew install nginx

To start the nginx server,

sudo nginx

Checking the status of the server by visiting the below URL in thebrowser

http://localhost:8080

Kudos. Installation was done successfully with the default configurations.

Let’s change the port to 80 using the below configurations

By default, after installing the nginx via home brew, config file will be present in the /opt/homebrew/etc/nginx/nginx.conf. Default html directory will be /opt/homebrew/var/www/

Stop the server using the below command

sudo nginx -s stop

Default server configurations will be present in the /opt/homebrew/etc/nginx/nginx.conf like below

 server {
listen 8080;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root html;
index index.html index.htm;
}

Change the configuration value of listen from 8080 to 80

 server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root html;
index index.html index.htm;
}

Relaunch the nginx server and access http://localhost

Note : make sure no other process is running in 80 port. Nginx version used here is 1.25.2

Refer Nginx docs here

This blog has been inspired from the post

--

--

Ram

Backend Developer | Security and Productivity Enthusiast