-3

By default Debian 9 comes with PHP 7, but I was interested in PHP 5 for older websites as well.

I tried following/adapting this guide (not virtualmin specific) https://pehapkari.cz/blog/2017/03/27/multiple-php-versions-the-easy-way/

But this is the error I was getting (because Virtualmin was detecting the wrong php binary):

[Tue Jan 22 15:08:58.713966 2019] [fcgid:warn] [pid 1023] (104)Connection reset by peer: [client MYIP:62256] mod_fcgid: error reading data from FastCGI server
[Tue Jan 22 15:08:58.714041 2019] [core:error] [pid 1023] [client MYIP:62256] End of script output before headers: test.php
5
  • Ive re-worded the title if thats what you want, as you can see ive already put quite a bit of effort into sharing here and on other stack sites. Jan 22, 2019 at 9:44
  • Then you should know that it is quite welcome to answer your own question, but you should post it as an answer, not a question. The question only needs what you have in the title, the rest belongs in an answer. I'll start a reopen vote, so you can move your solution into an answer. Jan 22, 2019 at 9:49
  • Sure let me just move it into the answer. Jan 22, 2019 at 10:21
  • It can be done, but it is unlikely that you can do it. Multiple php versions inside the same apache process might be problematic, but multiple php-fpm can work. However, from a system administration view, it might be better if you would use some paravirtualization or containers to use entirely different server instances on the same system.
    – peterh
    Jan 22, 2019 at 11:38
  • Thanks @peterh but i did get it to work and virtualmin has pretty god support for it, its just a matter of installing the right packages Jan 22, 2019 at 19:04

1 Answer 1

1

So first you need to add repository for PHP 5.6, "here are packages directly from a maintainer of Debian's PHP packages, Ondřej Surý."

$ apt-get install apt-transport-https
$ curl https://packages.sury.org/php/apt.gpg | apt-key add -
$ echo 'deb https://packages.sury.org/php/ stretch main' > /etc/apt/sources.list.d/deb.sury.org.list
$ apt-get update

Now the key is to install just the right php package, in the case of virtualmin running default FCGId mode, it is:

$ apt-get install php5.6-cgi

I also wanted mysql/i, gd & xml support so:

 $ apt-get install php5.6-mysql php5.6-gd php5.6-xml

These will both install a few dependencies as well.

Finally:

service apache2 restart

Now you should be able to run "System settings"->"Re-Check Configuration" and look for the line that should say something like this:

The following PHP versions are available : 5.6.40 (/usr/bin/php-cgi5.6), 7.0.33 (/usr/bin/php-cgi7.0)

Making sure that both bin's are -cgi variants, this was what got me as i had one detecting as plain php5.6 without the -cgi bit.

Now you should be able to go to "Server Configuration"->"PHP Versions" and select the new (older) version we installed.

Also now check if in "Services" you have an new option to configure the new 5.6 php.ini too, otherwise you need to go to "Server Configuration"->"Website Options" and change from FCGId to CGI wrapper and back to FCGId again, this will generate your php.ini in the new section.

Now finally you may want to comment out the new apt source we added earlier to stop your 'regular debian' php packages from being upgraded from

#deb https://packages.sury.org/php/ stretch main

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