In this tutorial,we’ll learn that how we can install the latest LEMP (Nginx, MySQL & PHP) Stack and it’s initial configuration on CentOS 6.5, because Base and EPEL repo are containing really old version of LEMP Stack.
Please add the required repos by using the following commands:
sudo rpm --import http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6
sudo rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
sudo yum repolist

We’ll have mysql55-libs conflicts with mysql-libs error, if we’ll proceed like this. To resolve this conflict, we need to issue these commands:
sudo yum install yum-plugin-replace
sudo yum replace mysql-libs --replace-with mysql55w-libs

Now, we can safely issue this command to install the latest version of Nginx, MySQL and PHP with PHP-Fpm:
sudo yum install nginx16 mysql55w mysql55w-server php55w php55w-opcache php55w-fpm

Enable Nginx, MySQL and PHP-FPM to automatically begin when the server boot:
sudo chkconfig nginx on
sudo chkconfig mysqld on
sudo chkconfig php-fpm on

Secure the PHP by editing the php.ini file:
sudo vi /etc/php.ini

Uncomment the cgi.fix_pathinfo and change it from 1 to 0:
cgi.fix_pathinfo=0

Edit the /etc/php-fpm.d/www.conf file:
sudo vi /etc/php-fpm.d/www.conf

Change the user and group:
user = nginx
group = nginx

Next we need to do some modification in default nginx.conf file:
sudo vi /etc/nginx/nginx.conf

Increase the worker processes from 1 to 4:

Also delete the default server config block to make the file more concise:

Move to the /etc/nginx/conf.d/ directory:
cd /etc/nginx/conf.d/

Next, we’ll create the virtual host file for our domain (In my case it’s rbgeek.conf):
sudo vi rbgeek.conf

This is a basic virtual host config file:
server {
listen 80;
server_name rbgeek.com;
access_log /var/log/nginx/rbgeek_access.log main;
error_log /var/log/nginx/rbgeek_error.log;
location / {
root /var/www/rbgeek;
index index.php index.html index.htm;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
root /var/www/rbgeek;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_intercept_errors on;
}
}

Finally, restart the Nginx and PHP-FPM services:
sudo service nginx restart
sudo service php-fpm restart

Create a directory structure for the website under /var/www/.If you have another preference, please update the config files accordingly:
sudo mkdir -p /var/www/rbgeek

Adjust the permission:
sudo chgrp -R nginx /var/www/rbgeek
sudo chmod g+s /var/www/rbgeek

Create a phpinfo page to verify that the php is working correctly with Nginx:
sudo vi /var/www/rbgeek/info.php

Add the following code in it:
<?php
phpinfo();
?>

Navigate to the site in web browser and verify that the php information is returned:
http://rbgeek.com/info.php

(Optional) Verify that all the packages are updated by using the code in your index page:

Hope this will help you!
Please Remember me in your prayers!
Enjoy 
Like this:
Like Loading...
Related