I installed PHP7 from Remi repo with

sudo yum -y install httpd
sudo yum -y install epel-release
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm 
sudo rpm -Uvh remi-release-6*.rpm
sudo yum -y --enablerepo=remi,remi-test install php70
scl enable php70 'php -v'
sudo ln -s /usr/bin/php70 /usr/bin/php

and it is working via CLI. Now I want to make it work with apache but i can't find a so to pass as a second argument to LoadModule

LoadModule php7_module        unknown_path  
<FilesMatch \.php$>
SetHandler application/x-httpd-php

Is this the correct approach to make PHP7 to work with apache2?


By default "php70" (Software Collection) don't install the mod_php.

yum install php70-php

And check you haven't any other mod_php (such as the one provided by "php" base package)

  • Hi Remi. I just installed on centos 6.7 (yum install php70-php-pear php70-php-bcmath php70-php-pecl-jsond-devel php70-php-mysqlnd php70-php-gd php70-php-common php70-php-fpm php70-php-intl php70-php-cli php70-php php70-php-xml php70-php-opcache php70-php-pecl-apcu php70-php-pecl-jsond php70-php-pdo php70-php-gmp php70-php-process php70-php-pecl-imagick php70-php-devel php70-php-mbstring) and while the install worked flawlessly my sites are still being served in php 5.6. How do I "switch" nginx over to php 7?
    – Codemonkey
    Dec 4 '15 at 8:47
  • Since fcgi passes over I assume I need to somehow disable 5.6 on that port and make it be php 7 instead... but my mind's gone blank! I'm guessing that if I uninstalled all of the 5.6 stuff first, and then installed 7, that would also resolve it?
    – Codemonkey
    Dec 4 '15 at 8:48
  • If you nedd a single php version, you can disable "php-fpm" and use "php70-php-fpm" instead. If you need both, change the listen option in the pool definition, and nginx configuration. Dec 4 '15 at 9:02
  • 3
    Fantastic, thanks. For anyone else in the same boat this does the trick: service php-fpm stop, service php70-php-fpm start. You'll find php.ini and php-fpm conf files in /etc/opt/remi/php70/ rather than just in etc.
    – Codemonkey
    Dec 4 '15 at 10:27
  • 1
    It works with "httpd" in base system. But if you use httpd24, you probably don't need "mod_php", rather use php-fpm (SetHandler to proxy is supported in recent versions) Jun 23 '16 at 13:37

FYI for those looking to install PHP 7 using the remi-php70 repository (now that PHP 7.0.0 has been released), you can install packages using the same package names you know and love, for example:

  • php
  • php-cli
  • php-common
  • php-devel
  • php-fpm
  • php-gd
  • php-mbstring
  • php-pdo
  • etc.
  • How? php54 seems to be the default with remi-release-7.rpm?
    – giorgio79
    Apr 9 '16 at 18:17
  • 1
    @giorgio79 if you enable remi-php70.repo and disable all other php versions from the remi repos, running yum install php-fpm by default uses 7.0, but this does NOT work with 7.1 (or other future releases)
    – sofly
    Jul 20 '16 at 22:07

For anyone else trying to upgrade from PHP 5.6 to 7.0.1 on Centos 6.7:

I managed to get this working today almost like @mbalparda has listed but without using epel-release (though a few epel repos are enabled and in use)

I had php 5.6 from IUS (https://ius.io/GettingStarted/) repo (https://centos6.iuscommunity.org/ius-release.rpm) installed, so I removed them by:

# yum list installed | grep php5
php56u.x86_64          5.6.14-1.ius.centos6
php56u-cli.x86_64      5.6.14-1.ius.centos6
php56u-common.x86_64   5.6.14-1.ius.centos6

and so

# yum erase php56u php56u-cli php56u-common php56u-mcrypt php56u-mysqlnd ...

followed by the listed commands:

# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm 
# rpm -Uvh remi-release-6.rpm
# yum install php70-php php70-php-cli php70-php-common php70-php-mcrypt php70-php-mysqlnd ...
# scl enable php70 'php -v'
# sudo ln -s /usr/bin/php70 /usr/bin/php
# service httpd restart
  • 1
    mixing php70-* and php56u-* package in the same command seems very strange. Probably unwanted. And if you want a single version, using the SCL is not the simplest solution. Simplest is to enable remi-php70 repository and "yum update". Remember to try the new wizard: rpms.remirepo.net/wizard Dec 31 '15 at 16:43
  • @RemiCollet thanks for pointing out the typo, edited the post to reflect the same - I meant to write php70-php-mysqlnd etc but copy-pasted / edited wrongly ... Also, the wizard seems superb. Thanks!
    – site80443
    Jan 1 '16 at 12:36
  • This worked for me to downgrade from PHP 7.2 to PHP 7.0 May 20 '20 at 0:23

PHP70 also seems to install everything under /etc/opt/remi/php70/:

you'll need to run:

source /opt/remi/php70/enable
  • 4
    You should elaborate. Why do you need to run that? What does it do? How does it help the OP find the Apache module?
    – Marki
    Apr 30 '16 at 13:34
  • If PHP 7 still doesn't work you'll need to run it to make it work. It will add a line in apache to load the php70 module. May 18 '16 at 6:34
  • 1
    this will stop working if you logout and log back in. this is the problem i am facing.
    – Edward
    Apr 28 '17 at 9:49
  • 1
    What the heck this one burned me on my 7.4 install! Added the PATH entries as needed and it's working. Sheesh no idea why it was designed like that!
    – emmdee
    Jan 6 '20 at 23:36

If you have older php version (like 5.6) installed, don't forget to do something like this:

cd /etc/httpd/conf.d/
mv php.conf php.conf.dis

Restart apache and that should do it.

  • 1
    Strangely, this solution fixed it for me after a few hours of mumbling around.
    – giorgio79
    Apr 9 '16 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.