Vasos Koupparis

Vasos Koupparis

Full Stack Web Developer – Devops Engineer

Nginx – Getting Started – Install Nginx on Windows, Linux and Mac OS

Step-by-step tutorial of how to download and install Nginx on Windows, Linux and Mac OS.

 

Nginx is one of the most popular and fastest growing open source web servers in the world.

Compared to apache is more resource-friendly, it can be used as a web server, reverse proxy, load balancer, mail proxy and HTTP cache.

Nginx is distributed as a package for all supported platforms and architectures and must first be installed on your machine.

Check out the releases CHANGELOG for more information on the latest release and choose the version that is required for your Operating System and your project. If you just getting started with Nginx , I suggest you to get the latest stable release.

Download Nginx

You can download a version of Nginx from the downloads service.

Install Nginx – Windows

  1. Download nginx for windows 
    • Note: Nginx is packaged as a zip archive, so after downloading Nginx, unzip the package. Nginx runs as nginx.exe.
  2. Copy files from the zip to “c:\nginx” for example. That’s our nginx PATH.
  3. The final step is to make sure that the nginx.exe is available on the PATH.

General Information

  • The PATH is the system variable that your operating system uses to locate needed executables from the command line or Terminal window.
  • The PATH system variable can be set using System Utility in control panel on Windows, or in your shell’s startup file on Linux.

Windows 10 and Windows 8

  1. In Search, search for and then select: System (Control Panel)
  2. Click the System and Security link.
  3. Click the System link.
  4. Click the Advanced system settings link.
  5. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  6. In the Edit System Variable (or New System Variable) window, append at the end of the PATH environment variable the value of nginx path ex.”c:\nginx\nginx.exe;” . Click OK. Close all remaining windows by clicking OK.
  7. Reopen Command prompt window, and run nginx.

Windows 7

  1. From the desktop, right click the Computer icon.
  2. Choose Properties from the context menu.
  3. Click the Advanced system settings link.
  4. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  5. In the Edit System Variable (or New System Variable) window, append at the end of the PATH environment variable the value of nginx path ex.”c:\nginx\nginx.exe;” . Click OK. Close all remaining windows by clicking OK.
  6. Reopen Command prompt window, and run nginx.

Windows XP

  1. Select Start, select Control Panel. double click System, and select the Advanced tab.
  2. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  3. In the Edit System Variable (or New System Variable) window, append at the end of the PATH environment variable the value of nginx path ex.”c:\nginx\nginx.exe;” . Click OK. Close all remaining windows by clicking OK.
  4. Reopen Command prompt window, and run nginx.

Install Nginx – Linux

Nginx is available pre-compiled on these Linux distributions and the installation is straight forward.

$ sudo apt-get -y update
$ sudo apt-get -y upgrade
$ sudo apt-get -y install nginx

How to compile and install manually, I will write a seperate article.

Install Nginx – Mac OS

The easiest and quickest way to install Nginx is using Homebrew.

$ brew install nginx

Verify Install

When you’re done, you should be able to run the nginx -h command and get the usage information:

Visit http://localhost:8080