CentOS is a fork of Red Hat Enterprise Linux (RHEL) and stands for Community Enterprise Operating System. It is a widely used OS on servers specially used by hosting companies to provide shared hosting.
Let's start by configuring CentOS for our development environment. Perform the following steps:
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
This will add the NGINX repo to CentOS.
sudo yum --showduplicates list Nginx
This will show you the latest stable releases. In our case, it displays NGINX 1.8.0 and NGINX 1.8.1.
sudo yum install Nginx
This will install NGINX.
systemctl enable Nginx.service
systemctl start Nginx.service
To check which version of NGINX is installed, issue the following command in the terminal:
Nginx –v
On our server, the NGINX version installed is 1.8.1.
Now, our web server is ready.
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
sudo yum –showduplicates list php70w
In our case, PHP 7.0.3 is available to install.
sudo yum install php70w php70w-common php70w-cli php70w-fpm php70w-mysql php70w-opcache php70w-mcrypt
sudo yum search php70w-
We will see a long list of all the available modules for PHP 7.
sudo yum install php70w-gd
This will install the gd module. Multiple modules can be installed using the same command and separating each module by a space, as we did in the initial installation of PHP.
Now, to check which version of PHP is installed, issue the following command:
php –v
In our case, PHP 7.0.3 is installed.
sudo systemctl start php-fpm sudo systemctl restart php-fpm sudo systemctl stop php-fpm
/etc/Nginx/conf.d/default.conf using either vi, nano, or any other editor of your choice. Now, make sure that two options are set in the server block, as follows:server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.php index.html index.htm;
The root option indicates the web document root where our website source code files will be placed. Index indicates the default files that will be loaded along with extensions. If any of these files are found, they will be executed by default, regardless of any file mentioned in the URLs.
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name;
include fastcgi_params;
}The preceding block is the most important configuration as it enables NGINX to communicate with PHP. The line fastcgi_pass 127.0.0.1:9000 tells NGINX that PHP FPM can be accessed on the 127.0.0.1 loopback IP on port 9000. The rest of the details are the same as those we discussed for Debian and Ubuntu.
info.php with the following contents:<?php phpinfo(); ?>
After saving the file, type http://server_ip/info.php or http://hostname/info.php, and we will get a page with complete information about PHP. If you see this page, congratulations! PHP runs alongside NGINX.
sudo yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
After the repo installation is completed, a message will be displayed stating the completion of the installation.
sudo yum search percona
sudo yum install Percona-Server-server-55
The installation process will start. The rest of the process is the same as for Debian/Ubuntu.