In this tutorial, I will explain how to install Nginx on a CentOS server / VPS. This is very easy and will not take more than 5 minutes.
Before starting installation of Nginx, make sure you have installed PHP and MySQL
How to install PHP
How to install MySQL
Login to your server via SSH and as root.
Step 1:
If you have already installed Apache and is running, stop Apache.
service httpd stop
Step 2:
Create nginx repo file.
touch /etc/yum.repos.d/nginx.repo
Step 3
Edit nginx repo file.
nano /etc/yum.repos.d/nginx.repo
And add following code. Save the file.
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1
Step 4
Install Nginx
yum install nginx
Step 5
Start Nginx
service nginx start
Step 6
Make nginx auto start on server reboot.
sudo chkconfig nginx on
Done!!
Default Web Directory
This is the default folder / directory of Nginx server. You should upload your website files in this directory.
/usr/share/nginx/html