How to install Nginx on Mac



This content originally appeared on DEV Community and was authored by Deepak Patil

Nginx is a widely used web server, valued for its speed and reliability in serving web content. Installing Nginx on macOS allows you to leverage its local development or testing capabilities. In this post, let’s understand the steps to install Nginx smoothly on your Mac, making it easy to manage and serve your web projects.

Although you can install Nginx from the source code on MacOS, it is a bit complex. So, HomeBrew is the best option for installing Nginx.

Steps to install Nginx on MacOS

Install Homebrew Package Manager

You can install Homebrew from official website or Just enter below command to install.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install Nginx

Use the homebrew command below to install nginx.

brew install nginx
Start & Use Nginx

Start the Nginx service using brew.

brew services start nginx

Now go to http://localhost:8080 and you should see the Nginx welcome page.
Below are some commands you can use for managing nginx service.

Stop

brew services stop nginx

Restart

brew services restart nginx

Status

brew services status nginx

By default nginx on Mac uses 8080 port. You can change nginx.conf and update the port number to 80 so that it will serve directly on localhost.

With Nginx now running on your macOS, you’re ready to explore and deploy web apps with nginx.


This content originally appeared on DEV Community and was authored by Deepak Patil