Introduction


NGINX is a web server with light resource consumption patterns. A main difference from Apache is that NGINX does not needs to spawn new processes or threads for each request.

 

In this tutorial we will show you how to install NGINX with yum on a CentOS server. You must have root privileges to be able to execute the installation commands.

 

Install EPEL


Linux package manager YUM does not include the latest version of NGINX in its default repository. Therefore, installing Extra Packages for Enterprise Linux (EPEL) will make sure it always stays up to date.

 

sudo su -c 'rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm'

 

Now EPEL packages are installed and ready to use.

 

Install NGINX


In the terminal window, type the following command:

 

sudo yum install nginx -y

 

You will get an output similar to this:

 

Loaded plugins: product-id, rhnplugin, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
nginx                                                    | 1.3 kB     00:00
nginx/primary                                            | 4.8 kB     00:00
nginx                                                                     33/33
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 0:1.2.6-1.el6.ngx will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package        Arch            Version                    Repository      Size
================================================================================
Installing:
 nginx          x86_64          1.2.6-1.el6.ngx            nginx          361 k
 
Transaction Summary
================================================================================
Install       1 Package(s)
 
Total download size: 361 k
Installed size: 835 k
Is this ok [y/N]: y
Downloading Packages:
nginx-1.2.6-1.el6.ngx.x86_64.rpm                         | 361 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : nginx-1.2.6-1.el6.ngx.x86_64                                 1/1
----------------------------------------------------------------------
 
Thanks for using NGINX!
 
Check out our community web site:
* http://nginx.org/en/support.html
 
If you have questions about commercial support for NGINX please visit:
* http://www.nginx.com/support.html
 
----------------------------------------------------------------------
Installed products updated.
  Verifying  : nginx-1.2.6-1.el6.ngx.x86_64                                 1/1
 
Installed:
  nginx.x86_64 0:1.2.6-1.el6.ngx
 
Complete!

 

Set NGINX to start at boot time:

 

chkconfig nginx on

 

Now, everytime you reboot your server, NGINX will be started automatically.

 

Start NGINX.

 

Once you have installed NGINX, it's time to manually start it:

 

sudo /etc/init.d/nginx start

 

Test NGINX


Now that is is installed you can direct your web browser to your server or VPS IP address.

 

http://12.34.56.789

 

You should get a page that says "Welcome to nginx” This confirms it is all set and ready to serve your web content.

 

NGINX Configuration and Log files (optional):


You can further customize the settings of your NGINX web server by changing the settings of its configuration files, you can also check the logs for any error debugging or simple maintenance routines. This files are:

 

  • -configuration directory: /etc/nginx/
  • -SSL and vhost config directory: /etc/nginx/conf.d/
  • -log file directory: /var/log/nginx/
  • -document root directory: /usr/share/nginx/html
  • -configuration file: /etc/nginx/nginx.conf
  • -server access log file: /var/log/nginx/access.log
  • -server error log file: /var/log/nginx/error.log
 
 

Test on a Miami VPS Now

or

Deploy on a Miami Dedicated Server

Was this answer helpful? 3 Users Found This Useful (9 Votes)