2

I have installed Fedora 25 on a server and need to downgrade php from 7 to 5.6. I have done the following:

dnf remove php
dnf remove php-common
wget https://rpms.remirepo.net/fedora/remi-release-25.rpm
rpm -Uvh remi-release-25.rpm
dnf --enablerepo=remi install php56 php56-php-common php56-php-cli php56-php-mbstring php56-php-mcrypt php56-php-pear php56-php-xml php56-runtime php56-php-mysqlnd

Everything worked fine but now everything is named php56 instead of php and so the system can't find anything. For example:

# php -r "echo 'Current PHP version: ' . phpversion();"
-bash: /usr/bin/php: No such file or directory
# php56 -r "echo 'Current PHP version: ' . phpversion();"
Current PHP version: 5.6.30

How do I take the last step and make everything (including packages) work like before?

I tried creating a symlink as follows, but php code does not run from the web, so the apache->php link is broken.

cd /usr/bin
ln -s /opt/remi/php56/root/usr/bin/php php

Thanks in advance.

3
  • You might want to install and use docker to easily use legacy packages.
    – Olivier
    Feb 27, 2017 at 22:49
  • If I install docker will all the thousands of lines of php code start working? Or do i have to reprogram everything to use docker containers?
    – xivix
    Feb 27, 2017 at 22:56
  • It will just work out of the box, you just need to pick the right image, like hub.docker.com/_/php, and use volumes to mount your local code into the container. Also you should check docker-compose for easy management. I'd say it's really worth the trouble!
    – Olivier
    Feb 27, 2017 at 23:04

1 Answer 1

3

This is how Software Collections are designed: parallel installation without altering base system and allow multiple versions. So /usr/bin/php is not provided on purpose.

You can read My PHP Workstation.

For mod_php (apache module), if you can remove "php" (base package) and install "php56-php" (which is missing in your list), it will work out of the box. If you can't remove "php", you can disable its LoadModule directive (/etc/httpd/conf.modules.d/15-php.conf), so the php5 module will be loaded (/etc/httpd/conf.modules.d/10-php56-php.conf).

For FPM (FastCgi server), when php56-php-fpm service runs you only have to adapt the path to the socket in webserver configuration (apache, nginx or lighttpd)

For CLI, you can use the module command (and most applications will find php and related commands in the PATH)

$ module load php56
$ php -v
PHP 5.6.30 (cli) (built: Jan 20 2017 17:58:52) 

And if you really want a single version, you can create the symlink, it will work:

$ ln -s /opt/remi/php56/root/usr/bin/php /usr/bin/php
$ php -v
PHP 5.6.30 (cli) (built: Jan 20 2017 17:58:52) 
3
  • Thank Remi! I finally found my missing piece was php56-php which installed the .conf file as you say and now phpinfo() confirms my Fedora 25 system is using php5.6. FYI Your PHP Workstation page says to install php56-fpm but dnf finds 'No match' and I see no such package at rpms.remirepo.net/fedora/25/remi/x86_64 .. I know almost nothing about FPM and think I'm happy using mod_php.
    – Neek
    Mar 13, 2017 at 6:34
  • Indeed it should be php56-php-fpm, blog post fixed. Mar 13, 2017 at 7:04
  • About FPM, you can read blog.remirepo.net/post/2016/05/30/… Mar 13, 2017 at 7:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .