This article assume that Nginx is installed in your server and its up and running.Lest install NginX
Update the repository
yum update -y
Install the EPEL repository
yum install epel-release -y
Install Dependencies
yum install -y git gcc gcc-c++ libxml2-devel pkgconfig openssl-devel bzip2-devel curl-devel libpng-devel libjpeg-devel libXpm-devel freetype-devel gmp-devel libmcrypt-devel mariadb-devel aspell-devel recode-devel autoconf bison re2c libicu-devel libxslt-devel libxslt
Get The PHP Source
curl -O -L https://github.com/php/php-src/archive/php-7.1.18.tar.gz tar -xvf php-7.1.18.tar.gz cd php-src-php-7.1.18/
Compile Source Code ./buildconf --force ./configure --prefix=/etc/php --with-config-file-path=/etc/php/etc --with-config-file-scan-dir=/etc/php/etc/conf.d --enable-bcmath --with-bz2 --with-curl --enable-filter --enable-fpm --with-gd --enable-gd-native-ttf --with-freetype-dir --with-jpeg-dir --with-png-dir --enable-intl --enable-mbstring --with-mcrypt --enable-mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-sqlite --disable-phpdbg --disable-phpdbg-webhelper --enable-opcache --with-openssl --enable-simplexml --with-sqlite3 --enable-xmlreader --enable-xmlwriter --enable-zip --with-zlib --enable-soap --with-xsl make make install
Add PHP to $PATH
echo 'pathmunge /etc/php/bin' > /etc/profile.d/php.sh
Copy php.ini
cp php.ini-development /etc/php/lib/php.ini
Add module opcache
vi /etc/php/etc/conf.d/modules.ini and add 'zend_extension=opcache.so'
PHP FPM SET UP
mkdir /etc/php/etc/conf.d cp sapi/fpm/www.conf /etc/php/etc/php-fpm.d/www.conf cp sapi/fpm/php-fpm.conf /etc/php/etc/php-fpm.conf
Update PHP FPM configuration
vi /etc/php/etc/php-fpm.d/www.conf user = nobody group = nobody listen.owner = nginx listen.group = nginx listen = /var/run/php-fpm/php-fpm.sock
Create a symlink for php-fpm to the standard path
ln -s /etc/php/sbin/php-fpm /usr/sbin/php-fpm
Create a systemctl file add the following:
vi /usr/lib/systemd/system/php-fpm.service [Unit] Description=The PHP FastCGI Process Manager After=syslog.target network.target [Service] Type=simple PIDFile=/run/php-fpm/php-fpm.pid ExecStart=/usr/sbin/php-fpm --nodaemonize --fpm-config /etc/php/etc/php-fpm.conf ExecReload=/bin/kill -USR2 $MAINPID [Install] WantedBy=multi-user.target
Create a run directory for php-fpm:
mkdir /run/php-fpm
Start php-fpm and Restart NginX
systemctl start php-fpm service nginx restart
Create index.php
mv /etc/nginx/html/index.html /etc/nginx/html/index.php
Update nginx.con file with the followinf content
root /etc/nginx/html; index index.php index.html index.htm; location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
Load URL
http://127.0.0.1/