sajad torkamani

Install Nginx

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:

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

Start Nginx

nginx

Visit localhost:8080 and you should see the default Nginx page. This page is found at /usr/local/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