Today we are going to install Nginx on Centos. Nginx (pronounced “Engine X”) is a lightweight web server that offers speed and flexibility without all of the extra features that larger web servers like Apache offer. Although it is a free and open source application, CentOS does not offer the latest version in its default YUM repository. To install it, you need to add the EPEL (Extra Packages for Enterprise Linux) repository, which is part of the Fedora Project.
First of all installing the EPEL repository:-
[p-root@unixsurgeon ~]# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5Server/i386/epel-release-5-4.noarch.rpm
Retrieving http://download.fedora.redhat.com/pub/epel/5Server/i386/epel-release-5-4.noarch.rpm
warning: /var/tmp/rpm-xfer.toDVXj: Header V3 DSA signature: NOKEY, key ID 217521f6
Preparing… ########################################### [100%]
1:epel-release ########################################### [100%]
Install nginx:-
[p-root@unixsurgeon ~]# yum install nginx
It will install nginx and ask gpg-key for EPEL, accept with yes option.
Now start your nginx web server.
[p-root@unixsurgeon ~]# service nginx start
Starting nginx: [ OK ]
The default document root of nginx server :- /usr/share/nginx/html
And the config file path is :- /etc/nginx/nginx.conf
Now open your browser and type 127.0.0.1 , it will open your default nginx page like below:-
http://127.0.0.1
The Default Document root is /usr/share/nginx/html….you should now put your content in a location of your choice and edit the root configuration directive in the nginx configuration file /et/nginx/nginx.conf.
