sajad torkamani

Install with Homebrew

Make sure you have Homebrew installed, then run:

brew install nginx

When Homebrew is finished installing, it will give you some useful info on how to use Nginx. In summary:

  • Document root is /opt/homebrew/var/www
  • Default port is set to 8080 in /usr/local/etc/nginx/nginx.conf
  • nginx will load all files in /opt/homebrew/etc/nginx/servers/

Start Nginx service

brew services start nginx

Visit localhost:8080 and you should see the default Nginx page. This page is found at /opt/homebre/var/www/index.html.

Add virtual hosts

You’ll probably want to setup server blocks to host different sites on your local machine. You can check out this post for more info. That post assumes an Ubuntu machine where Nginx typically loads files under /etc/nginx/sites-enabled instead of /usr/local/etc/nginx/servers .

Tagged: Nginx