if error occurs please verify package as follow:
gcc
libxml2-devel
pkgconfig
openssl-devel
bzip2-devel
curl-devel
libpng-devel
libpng-devel
libjpeg-devel
libXpm-devel
freetype-devel
gmp-devel
libmcrypt-devel
mariadb-devel
aspell-devel
recode-devel
httpd-devel
Download php stable version on http://php.net/downloads.php
#wget http://ar2.php.net/distributions/php-7.0.7.tar.gz
#tar xzvf php-7.0.7.tar.gz
#cd php-7.0.7
#./buildconf --force
./configure --prefix=/usr/local/php-7.0.7 --with-config-file-path=/usr/local/php-7.0.7/etc --with-config-file-scan-dir=/usr/local/php-7.0.7/etc/conf.d --enable-bcmath --with-bz2 --with-curl --enable-filter --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --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 --enable-xmlreader --enable-xmlwriter --enable-zip --with-zlib
#make install
If you ever have to recompile PHP you issue the command make clean and redo the last three steps.
Now we need to configure PHP to use FPM and add ini options so in your terminal add these commands
#sudo mkdir /usr/local/php-7.0.7/etc/conf.d
#sudo cp -v ./php.ini-production /usr/local/php-7.0.7/lib/php.ini
#sudo cp -v ./sapi/fpm/www.conf /usr/local/php-7.0.7/etc/php-fpm.d/www.conf
#sudo cp -v ./sapi/fpm/php-fpm.conf /usr/local/php-7.0.7/etc/php-fpm.conf
This copies the config files to our php7 directory and now want PHP to use opcache so we make the ini file for by
#vim /usr/local/php-7.0.7/etc/conf.d/modules.ini
Then add this in it and save the file
# Zend OPcache zend_extension=opcache.so
#vim /usr/local/php-7.0.7/etc/php-fpm.d/www.conf
and change these lines to suit the user you configured mine is ‘nginx’ so my lines would be
user = nginx
group = nginx
listen = /var/run/php-fpm/run/php-fpm.sock
listen.owner = nginx
listen.group = nginx
#ln -s /usr/local/php7/sbin/php-fpm /usr/sbin/php-fpm
Now make a server so we can start it at boot time so make and open the file use for centos 7 only but centos 6 goto #mkdir /var/run/php-fpm and start service php-fpm by: /usr/sbin/php-fpm and enter
#vim /usr/lib/systemd/system/php-fpm.service
then put this into it
[Unit] Description=The PHP FastCGI Process Manager After=syslog.target network.target [Service] Type=simple PIDFile=/var/run/php-fpm/php-fpm.pid ExecStart=/usr/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php-7.0.7/etc/php-fpm.conf ExecReload=/bin/kill -USR2 $MAINPID [Install] WantedBy=multi-user.target
#mkdir /var/run/php-fpm
Then enable the server and start it with
#chkconfig --levels 235 php-fpm on
#systemctl start php-fpm
Add php-fpm sock on nginx
#vim /etc/nginx/nginx.conf
[...]
location ~ \.php$ {
root /var/www/html;
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;
}
#uncommand this line
location ~ /\.ht {
deny all;
}
[...]
#/etc/init.d/nginx restart
And that should be it. You can check it by putting a php file in your web root with in it
<?php
phpinfo();
Verify version
#/usr/sbin/php-fpm -v
PHP 7.0.7 (fpm-fcgi) (built: Jun 8 2016 16:18:09)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
To restart service php-fpm
#systemctl restart php-fpm
===================
error:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
"Libmcrypt-devel'm such should have been put in yum, but ..."
hit the command and.
[root@test php-5.3.6]# yum install libmcrypt-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: rsync.atworks.co.jp
* extras: rsync.atworks.co.jp
* updates: rsync.atworks.co.jp
Setting up Install Process
No package libmcrypt-devel available.
Error: Nothing to do
=>32bit
#wget http://elders.princeton.edu/data/puias/unsupported/6/i386/libmcrypt-2.5.8-9.puias6.i686.rpm
#wget http://elders.princeton.edu/data/puias/unsupported/6/i386/libmcrypt-devel-2.5.8-9.puias6.i686.rpm
#rpm -ivh libmcrypt-2.5.8-9.puias6.i686.rpm
#rpm -ivh libmcrypt-devel-2.5.8-9.puias6.i686.rpm
=>46bit
#wget http://elders.princeton.edu/data/puias/unsupported/6/x86_64/libmcrypt-2.5.8-9.puias6.x86_64.rpm
#wget http://elders.princeton.edu/data/puias/unsupported/6/x86_64/libmcrypt-devel-2.5.8-9.puias6.x86_64.rpm
#rpm -ivh libmcrypt-2.5.8-9.puias6.x86_64.rpm
#rpm -ivh libmcrypt-devel-2.5.8-9.puias6.x86_64.rpm
=======================
http://www.shaunfreeman.name/compiling-php-7-on-centos/