Most UNIX and Linux distributions have Nginx included in their package manager repositories. Use package manager commands on your platform to install it. For example, use apt-get on Ubuntu or Debian, and emerge on Gentoo. For Red Hat, Fedora, or CentOS, see the instructions that follow.
You can find binary installation instructions for different platforms such as Red Hat and Ubuntu on the Nginx installation wiki at http://wiki.nginx.org/Install. However, we will briefly describe the process here, quoting from the wiki.
To add the Nginx yum repository, create a file named /etc/yum.repos.d/nginx.repo
and paste one of the following configurations:
CentOS, RHEL, and Scientific Linux, each populate the $releasever
variable differently. Therefore, depending on your OS version, replace $releasever
with 5
(for 5.x) or 6
(for 6.x). Therefore, baseurl
for 6.x would look like baseurl=http://nginx.org/packages/rhel/6/$basearch/
.
Append the following lines to the /etc/apt/sources.list
file, and replace the codename with the one appropriate for the release that you are using, for example, Ubuntu 13.10 is codenamed saucy
:
For Ubuntu 12.10:
deb http://nginx.org/packages/ubuntu/ saucy nginx deb-src http://nginx.org/packages/ubuntu/ saucy nginx
Please note that when you will run the apt-get update after adding the repository, you will get a GPG error of not being able to verify keys. If this happens and you find it hard to ignore it, do the following:
wget http://nginx.org/packages/keys/nginx_signing.key cat nginx_signing.key | sudo apt-key add -
For Debian 6:
For Ubuntu PPA: This PPA is maintained by volunteers and is not distributed by nginx.org. It has some additional compiled-in modules, and it may be more fitting for your environment. You can get the latest stable version of Nginx from Nginx PPA on Launchpad: You will require root privileges to execute the following commands.
For Ubuntu 10.04 and newer:
sudo -s nginx=stable # use nginx=development for latest development version add-apt-repository ppa:nginx/$nginx apt-get update apt-get install nginx
If you get an error about add-apt-repository not existing, you will want to install python-software-properties. For other Debian/Ubuntu based distributions, you can try the lucid variant of the PPA that is the most likely to work on older package sets.
sudo -s nginx=stable # use nginx=development for latest developmentversion echo "deb http://ppa.launchpad.net/nginx/$nginx/ubuntu lucidmain" > /etc/apt/sources.list.d/nginx-$nginx-lucid.list apt-key adv --keyserver keyserver.ubuntu.com --recv-keysC300EE8C apt-get update apt-get install nginx
Update the BSD ports tree using the following command:
# portsnap fetch update
Install the web server using the following commands:
# cd /usr/ports/www/nginx # make install clean
Type the following command to turn the Nginx server on:
echo 'nginx_enable="YES"' >> /etc/rc.conf
To start Nginx, enter:
# /usr/local/etc/rc.d/nginx start
OpenBSD, as of Version 5.1, includes Nginx as part of the base system. This means Nginx comes pre-installed along with all the library dependencies. The version is not always the latest and greatest one. However, this allows you to start migrating Apache applications over to Nginx. In the future, it is expected that the default httpd will be Nginx instead of Apache.
As of Version 0.8.50 of Nginx, the official Windows binary is now available.
The Windows version is provided as binary-only due to the current build process, which uses WineTools at the moment. You will not be able to compile a Windows version from source. Once you download the Windows ZIP file, perform the following steps:
Installation:
cd c:\ unzip nginx-1.2.3.zip ren nginx-1.2.3 nginx cd nginx start nginx
Control:
nginx -s [ stop | quit | reopen | reload ]
For problems, look in the c:\nginx\logs\error.log
file or in EventLog
.