Most of the yum repos doesn’t include PHP7.0.X on current releases for the time being. So if you need PHP7.0.X, you need to compile and build it for your self or you need to add additional repos to yum, which will be much more easier and much more flexible to update later. So, on a clean installed server proceed with the installation of Epel and Remi repos, in case you don’t have wget, also install it:

yum install epel-release
yum install net-tools, bind-utils # optional life savers 
rpm -Uvh http://mirror.veriteknik.net.tr/remi/enterprise/remi-release-7.rpm
yum install php70-php-fpm php70-php-cli php70-php-gd php70-php-json \
php70-php-mbstring php70-php-mcrypt php70-php-mysqlnd php70-php-xml
yum install nginx

 
Please note that if you need additional PHP packages, you can search them with the following command:

yum list php70-*
#Available Packages
#php70-php-opcache.x86_64
#.
#.
#php70-php-pecl-crypto.x86_64
#php70-php-pecl-geoip.x86_64 
#php70-php-pecl-imagick.x86_64
#php70-php-pecl-memcache.x86_64
#php70-php-pecl-xdebug.x86_64
#php70-php-pgsql.x86_64
#php70-php-soap.x86_64
#php70-php-xmlrpc.x86_64
#..
# and to install a package you desire, type the name:
yum install php70-php-pgsql

Run the following to enable systemd service for PHP-FPM:

systemctl enable php70-php-fpm
systemctl enable nginx

Disable SELINUX, set to disabled:

vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

type SHIFT+ZZ to save and exit, and for the time beign type setenforce 0 to disable SELINUX temproray.
Next step is to get rid of obsolete settings:

sed -i 's#;date.timezone =.*#  date.timezone = \ 
"Europe/Istanbul"#' /etc/opt/remi/php70/php.ini
sed -i 's#upload_max_filesize =.*#upload_max_filesize = \
200M#' /etc/opt/remi/php70/php.ini
sed -i 's#post_max_size =.*#post_max_size = \
200M#' /etc/opt/remi/php70/php.ini

You need to create the appropriate user account the fpm process will run on, as a sample we use plugged as a user:

useradd plugged
chmod 755 /home/plugged
mkdir /home/plugged/{logs,public_html,session}
touch /home/plugged/logs/{mphp_error.log,php-fpm-slow.log}
chown -R vtt:vtt /home/plugged/public_html/

create the php-fpm process config for the specific site:

cat <<< '[plugged] 
listen = 127.0.0.1:9001
listen.allowed_clients = 127.0.0.1 
listen.owner = plugged 
listen.group = plugged 
user = plugged 
group = plugged 
pm = dynamic 
pm.max_children = 50 
pm.start_servers = 5 
pm.min_spare_servers = 5 
pm.max_spare_servers = 35 
slowlog = /home/plugged/logs/php-fpm-slow.log 
catch_workers_output = yes 
php_admin_value[error_log] = /home/plugged/logs/mphp_error.log 
php_admin_flag[log_errors] = on 
php_value[session.save_handler] = files 
php_value[session.save_path] = /home/plugged/session ' \
> /etc/opt/remi/php70/php-fpm.d/plugged.conf

Turn on PHP-FPM by typing:

systemctl start php70-php-fpm.service

If it fails to start, you can check the logs by typing
systemctl status php70-php-fpm.service

Also please check the service is running by typing netstat so if the port is open, you should see that:

netstat -tulpn | grep php-fpm
#tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      908/php-fpm: master 
#tcp        0      0 127.0.0.1:9001          0.0.0.0:*               LISTEN      908/php-fpm: master 

please let us know if you find any mistake

Leave a Reply

Your email address will not be published. Required fields are marked *