DEV Community

Cover image for How to install Nginx on Mac
Deepak Patil
Deepak Patil

Posted on

How to install Nginx on Mac

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)"
Enter fullscreen mode Exit fullscreen mode
Install Nginx

Use the homebrew command below to install nginx.

brew install nginx
Enter fullscreen mode Exit fullscreen mode
Start & Use Nginx

Start the Nginx service using brew.

brew services start nginx
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Restart

brew services restart nginx
Enter fullscreen mode Exit fullscreen mode

Status

brew services status nginx
Enter fullscreen mode Exit fullscreen mode

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.


Top comments (0)