How to Install PHP 7 on Centos



Install PHP 7 on Centos


Step 1: you must add the Webtatic EL yum repository information corresponding to your CentOS/RHEL version to yum


CentOS/RHEL 7.x:


# 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

CentOS/RHEL 6.x:


# rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

Step 2: Now you can install PHP 7.0 (along with an opcode cache) by doing

# yum install -y --enablerepo=webtatic-testing php70w php70w-opcache php70w-bcmath php70w-cli
php70w-common php70w-dba php70w-devel php70w-embedded php70w-enchant php70w-fpm php70w-gd php70w-imap php70w-interbase php70w-intl php70w-ldap php70w-mbstring php70w-mcrypt php70w-mysql php70w-mysqlnd php70w-odbc php70w-pdo php70w-pdo_dblib php70w-pgsql php70w-process php70w-pspell php70w-recode php70w-snmp php70w-soap php70w-tidy php70w-xml php70w-xmlrpc

Step 3: Changes on the Module File for Php

# vi /etc/httpd/conf.d/php.conf

-- Line number 6 and 10 replace with these Lines

LoadModule php7_module modules/libphp7.s (replace with line nuber 6)
LoadModule php7_module modules/libphp7-zts.so (replace with line number 10)
AddHandler php7-script .php (replace with line number 16)

-- save and quit (:wq) --

Step 4: Create a php info file and check

# vi /var/www/html/info.php

<?php
phpinfo();
?>

-- save and quit (:wq) --

# service httpd restart

Step 5: check in browser http://IP-Address/info.php or check through CLI

# php -v

PHP 7.0.0RC2 (cli) (built: Sep  4 2015 21:04:20)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog.