How to downgrade from PHP 7.2 to 5.6?

php

#1

I have installed latest version of PHP at the moment which is 7.2 and that is great for most of my projects. But now I need older one 5.6 for one project.

I’ve put the following in my httpd.conf file:

#LoadModule php7_module modules/libphp7.so
LoadModule php5_module modules/libphp56.so

#AddHandler php7-script php
AddHandler php5-script php

#Include conf/extra/php7_module.conf
Include conf/extra/php56_module.conf

But when I run php -v I still get:

PHP 7.2.10 (cli) (built: Sep 11 2018 08:51:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Meanwhile php56 -v gives:

PHP 5.6.38 (cli) (built: Oct 15 2018 15:43:58)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

What more should I do to have PHP 5.6 version enabled?
Is there maybe some better way of handling multiple versions of PHP on Manjaro?


#2

change to:

AddHandler php5-script php56

#3

Hi @calvous, thanks for your reply.

Unfortunately this change didn’t do the trick for me. After httpd restart PHP version is still showing 7.2 even though projects that are built with 7.2 are not working.


#4

Another option is to use a virtual machine or Docker container which matches the production environment.


#5

Where it is showing that?

Please note that running php -v in a Terminal is not the same as letting a php script run thru Apache.

If you want to run php scripts in the terminal use php56. You also can remove the php package and then link the php56 binary to /usr/bin/php. If you want use the php command.


#6

of couse it shows version 7. editing the http file does not change any output on your console. If you ran php -v it simply tells the output of it’s own version which is php7 because the file in /usr/bin/php is just this interpreter.
What you did in your httpd config was just telling your Webserver to use the php56 interpreter.


#7

@xabbu yes I was running php -v in my terminal. I don’t actually need php commands, I just wanted to make 5.6 default one. And I thought this will let me know if 5.6 is default one or not.

Thanks for clarification.


#8

create an alias in your .bashrc

alias php=php56

this will change it for your user for every terminal session. No risk in doing so.


#9

have you restarted the httpd service after changing the httpd.conf file? Otherwise Apache will still run with the old configuration file.


#10

Also - is php 5.6 installed?

It is only available from AUR and I suspect it conflicts with php 7.2.


#11

#12

@calvous thanks for the tip, but I just needed to have 5.6 version enabled. And that was the case when I checked phpinfo() .

@Phrosgone yes, I have restarted httpd service upon every config change.

@fhdk yes, PHP 5.6 is installed and enabled, while 7.2 is installed but disabled.

Thanks to you all guys for your help and support!

At the end I just wanted to wrap this topic with my own words for whoever runs into similar issue:

Installing different PHP version and then enabling it in httpd.conf file really changes active PHP version. But as @xabbu and @calvous said, in terminal you will still get version 7.2 So you must check PHP version by putting phpinfo() in some test.php file and then navigate with your browser to it. So for now this is the easiest way to switch between multiple PHP versions in Manjaro.


#13

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.