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*
sudo yum --enablerepo=ius install php56u*
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