Now Nginx can be installed via yum on CentOS / REHL. Before you install it via yum, you will have to add necessary repo. You can follow the steps to add repo for Nginx:
For CentOS 6.x users:
[[email protected] ~]# cd /tmp
[[email protected] ~]# wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
[[email protected] ~]# rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm
For RHEL 6.x users:
[[email protected] ~]# cd /tmp
[[email protected] ~]# wget http://nginx.org/packages/rhel/6/noarch/RPMS/nginx-release-rhel-6-0.el6.ngx.noarch.rpm
[[email protected] ~]# rpm -ivh nginx-release-rhel-6-0.el6.ngx.noarch.rpm
Now, you can install nginx web server using yum:
[[email protected] ~]# yum install nginx
Once nginx is installed successfully, turn on service using chkconfig:
[[email protected] ~]# chkconfig nginx on
Following are the commands to start / restart / stop nginx web server:
[[email protected] ~]# service nginx start
[[email protected] ~]# service nginx restart
[[email protected] ~]# service nginx stop
[[email protected] ~]# service nginx status
[[email protected] ~]# service nginx reload
Now, you can edit nginx configuration file as per your need. The configuration file is available at following location:
/etc/nginx/nginx.conf