How to install PHP 5.6 on CentOS 7.0 x64
@trangunghoa Can you be more descriptive? I can install php56u just fine and make it work with httpd. What errors are you seeing?
i used ‘yum install php56u’. it’s not working
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
rpm -Uvh remi-release-7*.rpm epel-release-7*.rpm
If you already have EPEL installed:
rpm -Uvh remi-release-7*.rpm
Enabling the Repo
Now we need to make sure the repo is enabled and select which version you want to install. We need to head over to /etc/yum.repos.d you should inside see a file called remi.repo.
Open the file in your favourite editor (Nano, Pico, Vi etc), you’ll see a number of sections. We need to make sure that the first section [remi] is enabled:
name=Les RPM de remi pour Enterprise Linux 6 - $basearch
Note the line enabled=1 make sure this is set! Now technically you can actually go ahead and install PHP, but you will only get PHP 5.4.*. Which might be want to you want is so skip ahead to the next section!
If we want PHP 5.5 or PHP 5.6 we need to do a bit more work, further down in the repo.repo file you will see two additional sections [remi-php55] and [remi-php56], decide which PHP version you want to install and then enable the correct. So for PHP 5.6 we would change to:
name=Les RPM de remi de PHP 5.6 pour Enterprise Linux 6 - $basearch
# WARNING: If you enable this repository, you must also enable "remi"
Once you made your changes save your modified file and quit your editor.
sudo yum install php php-gd php-mysql php-mcrypt
As you can see PHP is installing version 5.5.20-2.el6.remi from the remi-php55 repo! Once you have hit Y to confirm the install restart apache and magical unicorns you have a better version of PHP!
You can also change your mind in the future by going back into the remi.repo file and enable a different PHP version and then run yum update and if you have moved from 5.5 to 5.6 it will upgrade PHP for you. If you want to downgrade for any reason you will need to remove PHP (sudo yum remove php*) and then reinstall the PHP modules you want.
Here is a link to a method that works fine for Centos 7. https://www.svnlabs.com/blogs/install-apache-mysql-php-5-6-on-centos-7/.
@umairali110 what is not working ? Do you use Apache or Nginx?
Welcome to Digitalocean
sudo yum install php php-mysql
Join 1M+ other developers and: