How to install multiple PHP versions in Virtualmin 6, Debian 9












1















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).



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









share|improve this question





























    1















    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).



    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









    share|improve this question



























      1












      1








      1








      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).



      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









      share|improve this question
















      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).



      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






      debian apache-httpd php webmin






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 28 at 11:05









      GAD3R

      26.5k1756110




      26.5k1756110










      asked Jan 27 at 23:34









      Hayden ThringHayden Thring

      1587




      1587






















          1 Answer
          1






          active

          oldest

          votes


















          2














          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 (eg it was an existing server) 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





          share|improve this answer
























          • I would just like to add a comment, that me attempting to share this solution on serverfault stack got me banned, go figure....

            – Hayden Thring
            Jan 28 at 0:13






          • 1





            It is better to keep the repository enabled to apply the security updates automatically.

            – GAD3R
            Jan 28 at 11:09













          • I definitely did think this, but then it was going to pull my updates for php 7 from there too, is it possible to prevent this ? (though it may not be that bad)

            – Hayden Thring
            Jan 28 at 20:03











          • php5.6 will receive the updates from the Ondřej Surý repository and php7 will receive the updates from debian repository. If you have the 2 php version installed on your system update-alternatives can be used to set php5.6 as default.

            – GAD3R
            Jan 28 at 21:05






          • 1





            no when sury repo is active it wants to pull 7 from there too instead of debian

            – Hayden Thring
            Jan 29 at 0:35











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f497091%2fhow-to-install-multiple-php-versions-in-virtualmin-6-debian-9%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          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 (eg it was an existing server) 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





          share|improve this answer
























          • I would just like to add a comment, that me attempting to share this solution on serverfault stack got me banned, go figure....

            – Hayden Thring
            Jan 28 at 0:13






          • 1





            It is better to keep the repository enabled to apply the security updates automatically.

            – GAD3R
            Jan 28 at 11:09













          • I definitely did think this, but then it was going to pull my updates for php 7 from there too, is it possible to prevent this ? (though it may not be that bad)

            – Hayden Thring
            Jan 28 at 20:03











          • php5.6 will receive the updates from the Ondřej Surý repository and php7 will receive the updates from debian repository. If you have the 2 php version installed on your system update-alternatives can be used to set php5.6 as default.

            – GAD3R
            Jan 28 at 21:05






          • 1





            no when sury repo is active it wants to pull 7 from there too instead of debian

            – Hayden Thring
            Jan 29 at 0:35
















          2














          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 (eg it was an existing server) 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





          share|improve this answer
























          • I would just like to add a comment, that me attempting to share this solution on serverfault stack got me banned, go figure....

            – Hayden Thring
            Jan 28 at 0:13






          • 1





            It is better to keep the repository enabled to apply the security updates automatically.

            – GAD3R
            Jan 28 at 11:09













          • I definitely did think this, but then it was going to pull my updates for php 7 from there too, is it possible to prevent this ? (though it may not be that bad)

            – Hayden Thring
            Jan 28 at 20:03











          • php5.6 will receive the updates from the Ondřej Surý repository and php7 will receive the updates from debian repository. If you have the 2 php version installed on your system update-alternatives can be used to set php5.6 as default.

            – GAD3R
            Jan 28 at 21:05






          • 1





            no when sury repo is active it wants to pull 7 from there too instead of debian

            – Hayden Thring
            Jan 29 at 0:35














          2












          2








          2







          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 (eg it was an existing server) 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





          share|improve this answer













          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 (eg it was an existing server) 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






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 27 at 23:34









          Hayden ThringHayden Thring

          1587




          1587













          • I would just like to add a comment, that me attempting to share this solution on serverfault stack got me banned, go figure....

            – Hayden Thring
            Jan 28 at 0:13






          • 1





            It is better to keep the repository enabled to apply the security updates automatically.

            – GAD3R
            Jan 28 at 11:09













          • I definitely did think this, but then it was going to pull my updates for php 7 from there too, is it possible to prevent this ? (though it may not be that bad)

            – Hayden Thring
            Jan 28 at 20:03











          • php5.6 will receive the updates from the Ondřej Surý repository and php7 will receive the updates from debian repository. If you have the 2 php version installed on your system update-alternatives can be used to set php5.6 as default.

            – GAD3R
            Jan 28 at 21:05






          • 1





            no when sury repo is active it wants to pull 7 from there too instead of debian

            – Hayden Thring
            Jan 29 at 0:35



















          • I would just like to add a comment, that me attempting to share this solution on serverfault stack got me banned, go figure....

            – Hayden Thring
            Jan 28 at 0:13






          • 1





            It is better to keep the repository enabled to apply the security updates automatically.

            – GAD3R
            Jan 28 at 11:09













          • I definitely did think this, but then it was going to pull my updates for php 7 from there too, is it possible to prevent this ? (though it may not be that bad)

            – Hayden Thring
            Jan 28 at 20:03











          • php5.6 will receive the updates from the Ondřej Surý repository and php7 will receive the updates from debian repository. If you have the 2 php version installed on your system update-alternatives can be used to set php5.6 as default.

            – GAD3R
            Jan 28 at 21:05






          • 1





            no when sury repo is active it wants to pull 7 from there too instead of debian

            – Hayden Thring
            Jan 29 at 0:35

















          I would just like to add a comment, that me attempting to share this solution on serverfault stack got me banned, go figure....

          – Hayden Thring
          Jan 28 at 0:13





          I would just like to add a comment, that me attempting to share this solution on serverfault stack got me banned, go figure....

          – Hayden Thring
          Jan 28 at 0:13




          1




          1





          It is better to keep the repository enabled to apply the security updates automatically.

          – GAD3R
          Jan 28 at 11:09







          It is better to keep the repository enabled to apply the security updates automatically.

          – GAD3R
          Jan 28 at 11:09















          I definitely did think this, but then it was going to pull my updates for php 7 from there too, is it possible to prevent this ? (though it may not be that bad)

          – Hayden Thring
          Jan 28 at 20:03





          I definitely did think this, but then it was going to pull my updates for php 7 from there too, is it possible to prevent this ? (though it may not be that bad)

          – Hayden Thring
          Jan 28 at 20:03













          php5.6 will receive the updates from the Ondřej Surý repository and php7 will receive the updates from debian repository. If you have the 2 php version installed on your system update-alternatives can be used to set php5.6 as default.

          – GAD3R
          Jan 28 at 21:05





          php5.6 will receive the updates from the Ondřej Surý repository and php7 will receive the updates from debian repository. If you have the 2 php version installed on your system update-alternatives can be used to set php5.6 as default.

          – GAD3R
          Jan 28 at 21:05




          1




          1





          no when sury repo is active it wants to pull 7 from there too instead of debian

          – Hayden Thring
          Jan 29 at 0:35





          no when sury repo is active it wants to pull 7 from there too instead of debian

          – Hayden Thring
          Jan 29 at 0:35


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f497091%2fhow-to-install-multiple-php-versions-in-virtualmin-6-debian-9%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

          is 'sed' thread safe

          How to make a Squid Proxy server?