Nginx Installation.
first need to update
sudo yum update
Install the Nginx
yum install nginx
Start the Nginx server
Service Nginx restart
after starting nginx server enter IP in web browser you can get nginx default page
Install MySQL to Manage Site Data
Install mysql-server
sudo yum install mysql-server
sudo mysql_install_db
Secure installation for the Root password reset
sudo mysql_secure_installation
Install PHP for Processing
Install php5-fpm
sudo yum install php5-fpm php5-mysql
Edit the Php.ini file
sudo vim /etc/php5/fpm/php.ini
in this file change 1 to 0
cgi.fix_pathinfo=0
need to restart our PHP processor
sudo service php5-fpm restart
Next, open the php-fpm configuration file www.conf.
Find the line that specifies the listen parameter, and change it so it looks like the following
listen = /var/run/php-fpm/php-fpm.sock
Next, find the lines that set the listen.owner and listen.group and uncomment them. They should look like this.
listen.owner = nginx
listen.group = nginx
listen.group = nginx
Lastly, find the lines that set the user and group and change their values from "apache" to "nginx":
user = nginx
group = nginx
group = nginx
Configure Nginx to Use our PHP Processor
sudo vim /etc/nginx/conf.d/virtual.conf
Currently, with the comments removed, the Nginx default server block file looks like this:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
server_name server_domain_name_or_IP;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Restart Nginx to make the necessary changes:
sudo service nginx restart
Create a PHP File to Test Configuration
sudo nano /usr/share/nginx/html/info.php
We can type this into the new file. This is valid PHP code that will return formatted information about our server
<?php
phpinfo();
?>
Now, you can visit this page in your web browser by visiting your server's domain name or public IP address followed by /info.php