CentOS 6
Sponsored Link

Install PHP 7.02016/07/28

 
The version of PHP in CentOS 6 repository is 5.3 but Install 7.0 with RPM package if you need.
[1] It's possible to install from Remi's Repository.
It's OK to install it even if 5.3 is already installed because 7.0 is located on another PATH.
[root@dlp ~]#
yum --enablerepo=remi-safe -y install php70
[2] PHP 7.0 is installed under the /opt directory and the link "/usr/bin/php70" is created.
If you'd like to access with "php", Load Environment variables like follows.
[root@dlp ~]#
php70 -v

PHP 7.0.9 (cli) (built: Jul 20 2016 17:07:04) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
[root@dlp ~]#
which php70

/usr/bin/php70
[root@dlp ~]#
ll /usr/bin/php70

lrwxrwxrwx. 1 root root 32 Jul 29 12:55 /usr/bin/php70 -> /opt/remi/php70/root/usr/bin/php
# load environment variables with SCL tool

[root@dlp ~]#
scl enable php70 bash

[root@dlp ~]#
php -v

PHP 5.6.5 (cli) (built: Mar 23 2016 19:16:57)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
[3] If you'd like to enable PHP 7.0 automatically at login time, configure like follows.
[root@dlp ~]#
vi /etc/profile.d/php70.sh
# create new

#!/bin/bash

source /opt/remi/php70/enable
export X_SCLS="`scl enable php70 'echo $X_SCLS'`"
[4] To use 7.0 on Apache httpd, Configure like follows.
# install from Remi

[root@dlp ~]#
yum --enablerepo=remi-safe -y install php70-php
# rename and disable if old version exists

[root@dlp ~]#
mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.org

[root@dlp ~]#
/etc/rc.d/init.d/httpd restart

# create phpinfo to verufy working

[root@dlp ~]#
echo '<?php phpinfo(); ?>' > /var/www/html/info.php

[root@dlp ~]#
curl http://localhost/info.php | grep 'PHP Version' | tail -1 | sed -e 's/<[^>]*>//g'

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 68819    0 68819    0     0  5529k      0 --:--:-- --:--:-- --:--:-- 6109k
PHP Version 7.0.9
Matched Content