This howto will instruct you how to correctly install PHP 5.5.or 5.6 on Official Centos installs.
- Setup IUS Repository:
- Install or update php:
- Replace the php.ini:
sudo cp /etc/php.ini /etc/php.ini_(backup)
sudo cp /etc/php.ini.rpmnew /etc/php.ini
sudo service httpd restart
as root:
Centos 6: rpm -Uvh https://centos6.iuscommunity.org/ius-release.rpm
Centos 7: rpm -Uvh https://centos7.iuscommunity.org/ius-release.rpm
Retrieving https://centos7.iuscommunity.org/ius-release.rpm
warning: /var/tmp/rpm-tmp.kNlmmL: Header V4 DSA/SHA1 Signature, key ID 9cd4953f: NOKEY
Preparing… ################################# [100%]
Updating / installing…
1:ius-release-1.0-14.ius.centos7 ################################# [100%]
Error:
Retrieving https://centos7.iuscommunity.org/ius-release.rpm
warning: /var/tmp/rpm-tmp.Fs8fPZ: Header V4 DSA/SHA1 Signature, key ID 9cd4953f: NOKEY
error: Failed dependencies:
epel-release = 7 is needed by ius-release-1.0-14.ius.centos7.noarch
Fix:
https://dl.fedoraproject.org/pub/epel/
or, as root:
Centos 6: rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
Centos 7: rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Retrieving https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
warning: /var/tmp/rpm-tmp.vTfUei: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing… ################################# [100%]
Updating / installing…
1:epel-release-7-5 ################################# [100%]
Centos 6 Only:
sudo yum --enablerepo=ius list php55u*
sudo yum --enablerepo=ius install php55u*
sudo yum --enablerepo=ius list php56u*
sudo yum --enablerepo=ius install php56u*
Centos 7:
sudo yum --enablerepo=ius list php56u*
List php56u packages
php56u.x86_64
php56u-bcmath.x86_64
php56u-cli.x86_64
php56u-common.x86_64
php56u-dba.x86_64
php56u-dbg.x86_64
php56u-debuginfo.x86_64
php56u-devel.x86_64
php56u-embedded.x86_64
php56u-enchant.x86_64
php56u-fpm.x86_64
php56u-gd.x86_64
php56u-gmp.x86_64
php56u-imap.x86_64
php56u-interbase.x86_64
php56u-intl.x86_64
php56u-ioncube-loader.x86_64
php56u-ioncube-loader-debuginfo.x86_64
php56u-ldap.x86_64
php56u-litespeed.x86_64
php56u-mbstring.x86_64
php56u-mcrypt.x86_64
php56u-mssql.x86_64
php56u-mysqlnd.x86_64
php56u-odbc.x86_64
php56u-opcache.x86_64
php56u-pdo.x86_64
php56u-pear.noarch
php56u-pecl-apcu.x86_64
php56u-pecl-apcu-debuginfo.x86_64
php56u-pecl-apcu-devel.x86_64
php56u-pecl-gearman.x86_64
php56u-pecl-gearman-debuginfo.x86_64
php56u-pecl-geoip.x86_64
php56u-pecl-geoip-debuginfo.x86_64
php56u-pecl-igbinary.x86_64
php56u-pecl-igbinary-debuginfo.x86_64
php56u-pecl-igbinary-devel.x86_64
php56u-pecl-imagick.x86_64
php56u-pecl-imagick-debuginfo.x86_64
php56u-pecl-jsonc.x86_64
php56u-pecl-jsonc-debuginfo.x86_64
php56u-pecl-jsonc-devel.x86_64
php56u-pecl-krb5.x86_64
php56u-pecl-krb5-debuginfo.x86_64
php56u-pecl-krb5-devel.x86_64
php56u-pecl-memcache.x86_64
php56u-pecl-memcache-debuginfo.x86_64
php56u-pecl-memcached.x86_64
php56u-pecl-memcached-debuginfo.x86_64
php56u-pecl-mongo.x86_64
php56u-pecl-mongo-debuginfo.x86_64
php56u-pecl-pthreads.x86_64
php56u-pecl-pthreads-debuginfo.x86_64
php56u-pecl-redis.x86_64
php56u-pecl-redis-debuginfo.x86_64
php56u-pecl-uploadprogress.x86_64
php56u-pecl-uploadprogress-debuginfo.x86_64
php56u-pecl-xdebug.x86_64
php56u-pecl-xdebug-debuginfo.x86_64
php56u-pgsql.x86_64
php56u-process.x86_64
php56u-pspell.x86_64
php56u-recode.x86_64
php56u-snmp.x86_64
php56u-soap.x86_64
php56u-tidy.x86_64
php56u-xcache.x86_64
php56u-xcache-admin.noarch
php56u-xcache-debuginfo.x86_64
php56u-xml.x86_64
php56u-xmlrpc.x86_64
sudo yum --enablerepo=ius install php56u*
Install php56u packages
Put this list into a text file:
php56u.x86_64
php56u-bcmath.x86_64
php56u-cli.x86_64
php56u-common.x86_64
php56u-fpm.x86_64
php56u-gd.x86_64
php56u-mbstring.x86_64
php56u-mcrypt.x86_64
php56u-mysqlnd.x86_64
php56u-opcache.x86_64
php56u-pdo.x86_64
php56u-xml.x86_64
php56u-xmlrpc.x86_64
Install with the following command below:
1 |
yum install `cat php56u.txt` |
Agree to import the IUS RPM signing Keys:
Importing GPG key 0x352C64E5:
Userid : “Fedora EPEL (7)
Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
Package : epel-release-7-5.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Is this ok [y/N]: y
Retrieving key from file:///etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY
Importing GPG key 0x9CD4953F:
Userid : “IUS Community Project
Fingerprint: 8b84 6e3a b3fe 6462 74e8 670f da22 1cdf 9cd4 953f
Package : ius-release-1.0-14.ius.centos7.noarch (installed)
From : /etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY
Is this ok [y/N]: y
Check to make sure it’s been installed/updated:
rpm -qa | grep -i php
If you’ve already had php installed previously (i.e. you used the update method above) then run this command:
If not then simply restart httpd:
sudo service httpd restart
Troubleshooting / How To Test
Explanation troubleshooting basics and expectations.
- create and save a file called phpinfo.php in your httpd Documentroot with only this in it:
- Let’s go test and make sure we can see the current php version and other information:
- Make sure httpd is started, also make sure you have correctly replaced the php.ini file if you had previously installed php from official Centos repos.
1 |
<?php phpinfo(); ?> |
Open a web browser and navigate to: http://www.example.com/phpinfo.php
sudo service httpd status
Disclaimer
We test this stuff on our own machines, really we do. But you may run into problems, if you do, come to #centoshelp on irc.freenode.net