Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Php7 and php5 on fedora at the same time

How can I setup PHP5 and PHP7 on one Fedora system?

As I see, PHP in fedora is not one directory, it's spread in OS.

On Windows systems, PHP is one folder, so I can just rename it when I need a specific version of PHP. What about Fedora?

Maybe there are some useful links but I haven't found them.

Also, it will be php5+apache(httpd) and php7+nginx, but I don't think it matters for now.

like image 412
Kirill Fimchenko Avatar asked Mar 06 '16 17:03

Kirill Fimchenko


People also ask

Can you run multiple versions of PHP at the same time?

Together, you can use Apache and PHP-FPM to host multiple PHP web-applications, each using a different version of PHP, all on the same server, and all at the same time.

How can I run two versions of PHP?

To run two or more PHP versions for different sites on the same LAMP stack by using mod_fcgid to create a . fcgi wrapper script. The script forwards all the PHP requests which were made from php-cgi binary. Considering a server running on PHP 7.2 where a specific site requires an older PHP version (eg PHP 5.6).

Is php5 supported?

PHP 5 or PHP 7 Since January 1, 2019, PHP 5 is no longer supported with security fixes, starting on 1 January.


2 Answers

I suggest you to install remi repository. I assume you use fedora 23.

sudo dnf install http://rpms.remirepo.net/fedora/remi-release-23.rpm

After installing remi repository, you have to edit /etc/yum.repos.d/remi.repo file and enable it. Finally you can install various versions of php. for example:

sudo dnf install php70-php php56-php

You can use them as php70 and php56 along with option or php file you want to run.

like image 73
Ali Yousefi Sabzevar Avatar answered Oct 27 '22 01:10

Ali Yousefi Sabzevar


Following directions in Remi RPM repo blog worked for me. I can now run php55 or php70. https://blog.remirepo.net/post/2016/04/16/My-PHP-Workstation

Few things that it took to switch to php55:

 module unload php70
 module load php55

 yum install php55-php-fpm

 systemctl start php55-php-fpm
 systemctl enable php55-php-fpm

now both php --version in command line shows PHP 5.5 and also in your browser you will see that phpinfo() shows PHP 5.5.

like image 42
Tim Hysniu Avatar answered Oct 26 '22 23:10

Tim Hysniu