This all changed with the release of Apache 2.4, which has an event based model with Worker MPM. Why choose Nginx over Apache today? You might be familiar with some of the following companies that utilize Nginx:
- Netflix
- Hulu
- CloudFlare
- WordPress.com
- Github
- RightScale
All of these are very visible sites that receive incredibly high amounts of traffic daily, kept running fast thanks in part to Nginx and the server’s low resource consumption.
This guide will have everything you need to get Nginx installed on your new RHEL or Debian based Linux. Feel free to copy/paste everything after the “:” for your convenience.
Installation on RHEL based OS
Install Nginx on RHEL 6.x with the following steps:
- Check for system updates: sudo yum update
- Create file to discover repository URL (Using VI text editor in this example):
sudo vi /etc/yum.repos.d/nginx.repo
- Enter write mode: i
- Paste the following configurations:
[nginx] name=nginx repo baseurl=http://nginx.org/packages/rhel/6/$basearch/ gpgcheck=0 enabled=1
- Press Esc to return to read mode.
- Press Ctrl + X to save and quit the file
.
- Install the newly added repo:
sudo yum install nginx.x86_64
- Start the service:
sudo service nginx start
- Have the service start upon reboot:
sudo chkconfig nginx on
- You’re done! You can verify the service is now running on default port 80 by running the following:
netstat –tnlp
Note: If you’re running RHEL 5.x instead, simply replace the configuration line
baseurl=http://nginx.org/packages/rhel/6/$basearch/
with:
baseurl=http://nginx.org/packages/rhel/5/$basearch/
Install Nginx on CentOS 6.x with the following steps:
- Check for system updates:
sudo yum update
- Create file to discover repository URL (Using VI text editor in this example):
sudo vi /etc/yum.repos.d/nginx.repo
- Enter write mode: i
- Paste the following configurations:
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/6/$basearch/ gpgcheck=0 enabled=1
- Press Esc to return to read mode
- Press ctrl+x to save and quit thefile
.
- Install the newly added repo:
sudo yum install nginx.x86_64
- Start the service:
sudo service nginx start
- Set the service start upon reboot:
sudo chkconfig nginx on
- You’re done! You can verify the service is now running on default port 80 by running the following command:
netstat –tnlp
Note : If you’re running CentOS 5.x instead, simply replace the configuration line:
baseurl=http://nginx.org/packages/centos/6/$basearch/
with
baseurl=http://nginx.org/packages/centos/5/$basearch/
instead.
Installation on Debian based OS
Install Nginx on Debian 7.x with the following steps:
- Check for system updates:
sudo apt-get update
- Create file to discover repository URL (Using nano text editor in this example):
sudo nano /etc/apt/sources.list
- Paste the following configurations:
deb http://nginx.org/packages/debian/ squeeze nginx deb-src http://nginx.org/packages/debian/ squeeze nginx
- Press Ctrl+x to save and quit the file, press y to overwrite, then press Enter to confirm save.
- Install the newly added repo:
sudo apt-get install nginx
- Start the service:
sudo service nginx start
- Have the service start upon reboot:
sudo /usr/sbin/update-rc.d -f nginx defaults
- You’re done! You can verify the service is now running on default port 80 by running the following command:
netstat –tnlp
Note: If you’re running Debian 6.x instead, simply replace the configuration lines from:
deb http://nginx.org/packages/debian/ wheezy nginx deb-src http://nginx.org/packages/debian/ wheezy nginx
to:
deb http://nginx.org/packages/debian/ squeeze nginx
deb-src http://nginx.org/packages/debian/ squeeze nginx
Install Nginx on Ubuntu 14.04 LTS Trusty Tahr with the following steps:
- Check for system updates:
sudo apt-get update
- Create file to discover repository URL (Using nano text editor in this example):
sudo nano /etc/apt/sources.list
- Paste the following configurations:
deb http://nginx.org/packages/ubuntu/ trusty nginx deb-src http://nginx.org/packages/ubuntu/ trusty nginx
- Press ctrl+x to save and quit the file, press y to overwrite, then press Enter to confirm save.
- Install the newly added repo:
sudo apt-get install nginx
- Start the service:
sudo service nginx start
- Set the service start upon reboot:
sudo /usr/sbin/update-rc.d -f nginx defaults
(This should be set as default already.)
- You’re done! You can verify the service is now running on default port 80 by running the following command:
netstat –tnlp
Note : If you’re running Ubuntu 12.04 Precise Pangolin instead, simply replace the configuration lines from:
deb http://nginx.org/packages/ubuntu/ trusty nginx deb-src http://nginx.org/packages/ubuntu/ trusty nginx
To:
deb http://nginx.org/packages/ubuntu/ precise nginx deb-src http://nginx.org/packages/ubuntu/ precise nginx