Tutorial

How To Install nginx on CentOS 6 with yum

Published on May 22, 2012
How To Install nginx on CentOS 6 with yum
Not using CentOS 6?Choose a different version or distribution.
CentOS 6

Status: Deprecated

This article covers a version of CentOS that is no longer supported. If you are currently operating a server running CentOS 6, we highly recommend upgrading or migrating to a supported version of CentOS.

Reason: CentOS 6 reached end of life (EOL) on November 30th, 2020 and no longer receives security patches or updates. For this reason, this guide is no longer maintained.

See Instead:
This guide might still be useful as a reference, but may not work on other CentOS releases. If available, we strongly recommend using a guide written for the version of CentOS you are using.

The following DigitalOcean tutorial may be of immediate interest, as it outlines installing Nginx on a CentOS 7 server:


About Nginx

nginx is a high performance web server software. It is a much more flexible and lightweight program than apache.

Set Up

The steps in this tutorial require the user to have root privileges. You can see how to set that up in the CentOS Initial Server Setup Tutorial in steps 3 and 4.

Step One—Install EPEL

EPEL stands for Extra Packages for Enterprise Linux. Because yum as a package manager does not include the latest version of nginx in its default repository, installing EPEL will make sure that nginx on CentOS stays up to date.

To install EPEL, open terminal and type in:

sudo yum install epel-release

Step Two—Install nginx

To install nginx, open terminal and type in:

sudo yum install nginx

After you answer yes to the prompt twice (the first time relates to importing the EPEL gpg-key), nginx will finish installing on your virtual private server.

Step Three—Start nginx

nginx does not start on its own. To get nginx running, type:

sudo /etc/init.d/nginx start

You can confirm that nginx has installed on your VPS by directing your browser to your IP address.

You can run the following command to reveal your server’s IP address.

ifconfig eth0 | grep inet | awk '{ print $2 }'

On the page, you will see the words, “Welcome to nginx”

Congratulations! You have now installed nginx.

See More

Once you have nginx installed on your cloud server, you can go on to install the Lemp Stack or Set Up a FTP Server

By Etel Sverdlov

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
10 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Note, Installing EPEL will fail with the current URL listed, I switched the command to be: sudo su -c ‘rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

And that worked then with the switch from 6.7 to 6.8

I would suggest using official nginx repository which always has latest version: su -c ‘rpm -Uhv http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm’ su -c ‘yum install -y nginx’

I followed these instructions and the response header shows “Server:nginx/1.0.15”. According to http://nginx.org/ the latest version is 1.5.8. When “EPEL will make sure that nginx on CentOS stays up to date”?

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
January 1, 2014

@kapitalisti: What’s the output of <pre>repoquery -i nginx</pre>?

Name : nginx Version : 1.0.15 Release : 5.el6 Architecture: x86_64 Size : 1117650 Packager : Fedora Project Group : System Environment/Daemons URL : http://nginx.org/ Repository : epel Summary : A high performance web server and reverse proxy server Source : nginx-1.0.15-5.el6.src.rpm Description : Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and IMAP protocols, with a strong focus on high concurrency, performance and low memory usage.

Why should I compile? I thought I’ll just install it as instructed here:

http://nginx.org/en/linux_packages.html

Or do I need to uninstall something first?

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
January 1, 2014

@kapitalisti: I had no idea there’s an official nginx repo for CentOS, never really bothered checking. Uninstall the outdated nginx package and follow <a href=“http://nginx.org/en/linux_packages.html”>http://nginx.org/en/linux_packages.html</a>'s instructions.

How can I upgrade my nginx? Thanks for your help!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.