How to use different versions of PHP? [duplicate]











up vote
1
down vote

favorite













This question already has an answer here:




  • How do I install different (upgrade or downgrade) PHP version in still supported Ubuntu release?

    2 answers




I have several virtualhosts, and I need to run different PHP versions. I have php-fpm and FastCgi installed, but how can I configure it?
I'm using Ubuntu 16.04










share|improve this question















marked as duplicate by Zanna, Sergiy Kolodyazhnyy, Fabby, Thomas, Eric Carvalho Dec 2 at 16:44


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • If one of the answers solved your question, please mark that answer as the accepted one by clicking the gray checkmark next to up/down arrows on that answer
    – Sergiy Kolodyazhnyy
    Nov 30 at 8:35















up vote
1
down vote

favorite













This question already has an answer here:




  • How do I install different (upgrade or downgrade) PHP version in still supported Ubuntu release?

    2 answers




I have several virtualhosts, and I need to run different PHP versions. I have php-fpm and FastCgi installed, but how can I configure it?
I'm using Ubuntu 16.04










share|improve this question















marked as duplicate by Zanna, Sergiy Kolodyazhnyy, Fabby, Thomas, Eric Carvalho Dec 2 at 16:44


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • If one of the answers solved your question, please mark that answer as the accepted one by clicking the gray checkmark next to up/down arrows on that answer
    – Sergiy Kolodyazhnyy
    Nov 30 at 8:35













up vote
1
down vote

favorite









up vote
1
down vote

favorite












This question already has an answer here:




  • How do I install different (upgrade or downgrade) PHP version in still supported Ubuntu release?

    2 answers




I have several virtualhosts, and I need to run different PHP versions. I have php-fpm and FastCgi installed, but how can I configure it?
I'm using Ubuntu 16.04










share|improve this question
















This question already has an answer here:




  • How do I install different (upgrade or downgrade) PHP version in still supported Ubuntu release?

    2 answers




I have several virtualhosts, and I need to run different PHP versions. I have php-fpm and FastCgi installed, but how can I configure it?
I'm using Ubuntu 16.04





This question already has an answer here:




  • How do I install different (upgrade or downgrade) PHP version in still supported Ubuntu release?

    2 answers








apache2 php






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 30 at 9:37

























asked Nov 30 at 7:49









Santy Alvarez

356




356




marked as duplicate by Zanna, Sergiy Kolodyazhnyy, Fabby, Thomas, Eric Carvalho Dec 2 at 16:44


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Zanna, Sergiy Kolodyazhnyy, Fabby, Thomas, Eric Carvalho Dec 2 at 16:44


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • If one of the answers solved your question, please mark that answer as the accepted one by clicking the gray checkmark next to up/down arrows on that answer
    – Sergiy Kolodyazhnyy
    Nov 30 at 8:35


















  • If one of the answers solved your question, please mark that answer as the accepted one by clicking the gray checkmark next to up/down arrows on that answer
    – Sergiy Kolodyazhnyy
    Nov 30 at 8:35
















If one of the answers solved your question, please mark that answer as the accepted one by clicking the gray checkmark next to up/down arrows on that answer
– Sergiy Kolodyazhnyy
Nov 30 at 8:35




If one of the answers solved your question, please mark that answer as the accepted one by clicking the gray checkmark next to up/down arrows on that answer
– Sergiy Kolodyazhnyy
Nov 30 at 8:35










2 Answers
2






active

oldest

votes

















up vote
0
down vote



accepted










With nginx, all you have to do is use sockets via proxy_pass:



server{
(...)
location ~ ^/index.php(/|$) {
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
}


With apache you need to use proxy:



<FilesMatch ".php$">
SetHandler "proxy:unix:/var/run/php/php7.2-fpm.sock|fcgi://localhost/"
</FilesMatch>


This way, you can use different sockets (each for different version of PHP) by configuring them within each Virtual Host






share|improve this answer





















  • I'm new here, where I find the config file to put these? @janmyszkier
    – Santy Alvarez
    Nov 30 at 8:08










  • for apache it's /etc/apache2/sites-available and for nginx /etc/nginx/sites-available
    – janmyszkier
    Nov 30 at 8:30




















up vote
1
down vote













Maybe not the response that you're waiting for, but it gets painful to manage several php versions in your machine.



I've found that the best approach is to have a newer php version (php7+) as primary, and if I need something older or another specific version, I use a container with apache/php from here or use this as base image and modify it as necessary, it has great instructions to do that.



In the case that I need an older php version (unsupported so be careful), I can just build from an older OS version with support for that particular version.



The advantages of this approach are, first, that you don't mess up your machine with lots of packages and dependencies. Second, you don't pollute your php install with all the dependencies and packages that eventually will conflict with each other due to version-incompatibility. Finally, and super importantly, dockerizing apps will give you a replicable recipe for your production environment.



Even if you don't choose this as your approach, take a look at docker. It will make your like easier and it's "the thing" used in development nowadays.






share|improve this answer






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    With nginx, all you have to do is use sockets via proxy_pass:



    server{
    (...)
    location ~ ^/index.php(/|$) {
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT $realpath_root;
    }
    }


    With apache you need to use proxy:



    <FilesMatch ".php$">
    SetHandler "proxy:unix:/var/run/php/php7.2-fpm.sock|fcgi://localhost/"
    </FilesMatch>


    This way, you can use different sockets (each for different version of PHP) by configuring them within each Virtual Host






    share|improve this answer





















    • I'm new here, where I find the config file to put these? @janmyszkier
      – Santy Alvarez
      Nov 30 at 8:08










    • for apache it's /etc/apache2/sites-available and for nginx /etc/nginx/sites-available
      – janmyszkier
      Nov 30 at 8:30

















    up vote
    0
    down vote



    accepted










    With nginx, all you have to do is use sockets via proxy_pass:



    server{
    (...)
    location ~ ^/index.php(/|$) {
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT $realpath_root;
    }
    }


    With apache you need to use proxy:



    <FilesMatch ".php$">
    SetHandler "proxy:unix:/var/run/php/php7.2-fpm.sock|fcgi://localhost/"
    </FilesMatch>


    This way, you can use different sockets (each for different version of PHP) by configuring them within each Virtual Host






    share|improve this answer





















    • I'm new here, where I find the config file to put these? @janmyszkier
      – Santy Alvarez
      Nov 30 at 8:08










    • for apache it's /etc/apache2/sites-available and for nginx /etc/nginx/sites-available
      – janmyszkier
      Nov 30 at 8:30















    up vote
    0
    down vote



    accepted







    up vote
    0
    down vote



    accepted






    With nginx, all you have to do is use sockets via proxy_pass:



    server{
    (...)
    location ~ ^/index.php(/|$) {
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT $realpath_root;
    }
    }


    With apache you need to use proxy:



    <FilesMatch ".php$">
    SetHandler "proxy:unix:/var/run/php/php7.2-fpm.sock|fcgi://localhost/"
    </FilesMatch>


    This way, you can use different sockets (each for different version of PHP) by configuring them within each Virtual Host






    share|improve this answer












    With nginx, all you have to do is use sockets via proxy_pass:



    server{
    (...)
    location ~ ^/index.php(/|$) {
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT $realpath_root;
    }
    }


    With apache you need to use proxy:



    <FilesMatch ".php$">
    SetHandler "proxy:unix:/var/run/php/php7.2-fpm.sock|fcgi://localhost/"
    </FilesMatch>


    This way, you can use different sockets (each for different version of PHP) by configuring them within each Virtual Host







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 30 at 7:58









    janmyszkier

    50827




    50827












    • I'm new here, where I find the config file to put these? @janmyszkier
      – Santy Alvarez
      Nov 30 at 8:08










    • for apache it's /etc/apache2/sites-available and for nginx /etc/nginx/sites-available
      – janmyszkier
      Nov 30 at 8:30




















    • I'm new here, where I find the config file to put these? @janmyszkier
      – Santy Alvarez
      Nov 30 at 8:08










    • for apache it's /etc/apache2/sites-available and for nginx /etc/nginx/sites-available
      – janmyszkier
      Nov 30 at 8:30


















    I'm new here, where I find the config file to put these? @janmyszkier
    – Santy Alvarez
    Nov 30 at 8:08




    I'm new here, where I find the config file to put these? @janmyszkier
    – Santy Alvarez
    Nov 30 at 8:08












    for apache it's /etc/apache2/sites-available and for nginx /etc/nginx/sites-available
    – janmyszkier
    Nov 30 at 8:30






    for apache it's /etc/apache2/sites-available and for nginx /etc/nginx/sites-available
    – janmyszkier
    Nov 30 at 8:30














    up vote
    1
    down vote













    Maybe not the response that you're waiting for, but it gets painful to manage several php versions in your machine.



    I've found that the best approach is to have a newer php version (php7+) as primary, and if I need something older or another specific version, I use a container with apache/php from here or use this as base image and modify it as necessary, it has great instructions to do that.



    In the case that I need an older php version (unsupported so be careful), I can just build from an older OS version with support for that particular version.



    The advantages of this approach are, first, that you don't mess up your machine with lots of packages and dependencies. Second, you don't pollute your php install with all the dependencies and packages that eventually will conflict with each other due to version-incompatibility. Finally, and super importantly, dockerizing apps will give you a replicable recipe for your production environment.



    Even if you don't choose this as your approach, take a look at docker. It will make your like easier and it's "the thing" used in development nowadays.






    share|improve this answer



























      up vote
      1
      down vote













      Maybe not the response that you're waiting for, but it gets painful to manage several php versions in your machine.



      I've found that the best approach is to have a newer php version (php7+) as primary, and if I need something older or another specific version, I use a container with apache/php from here or use this as base image and modify it as necessary, it has great instructions to do that.



      In the case that I need an older php version (unsupported so be careful), I can just build from an older OS version with support for that particular version.



      The advantages of this approach are, first, that you don't mess up your machine with lots of packages and dependencies. Second, you don't pollute your php install with all the dependencies and packages that eventually will conflict with each other due to version-incompatibility. Finally, and super importantly, dockerizing apps will give you a replicable recipe for your production environment.



      Even if you don't choose this as your approach, take a look at docker. It will make your like easier and it's "the thing" used in development nowadays.






      share|improve this answer

























        up vote
        1
        down vote










        up vote
        1
        down vote









        Maybe not the response that you're waiting for, but it gets painful to manage several php versions in your machine.



        I've found that the best approach is to have a newer php version (php7+) as primary, and if I need something older or another specific version, I use a container with apache/php from here or use this as base image and modify it as necessary, it has great instructions to do that.



        In the case that I need an older php version (unsupported so be careful), I can just build from an older OS version with support for that particular version.



        The advantages of this approach are, first, that you don't mess up your machine with lots of packages and dependencies. Second, you don't pollute your php install with all the dependencies and packages that eventually will conflict with each other due to version-incompatibility. Finally, and super importantly, dockerizing apps will give you a replicable recipe for your production environment.



        Even if you don't choose this as your approach, take a look at docker. It will make your like easier and it's "the thing" used in development nowadays.






        share|improve this answer














        Maybe not the response that you're waiting for, but it gets painful to manage several php versions in your machine.



        I've found that the best approach is to have a newer php version (php7+) as primary, and if I need something older or another specific version, I use a container with apache/php from here or use this as base image and modify it as necessary, it has great instructions to do that.



        In the case that I need an older php version (unsupported so be careful), I can just build from an older OS version with support for that particular version.



        The advantages of this approach are, first, that you don't mess up your machine with lots of packages and dependencies. Second, you don't pollute your php install with all the dependencies and packages that eventually will conflict with each other due to version-incompatibility. Finally, and super importantly, dockerizing apps will give you a replicable recipe for your production environment.



        Even if you don't choose this as your approach, take a look at docker. It will make your like easier and it's "the thing" used in development nowadays.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 30 at 8:50









        Zanna

        49.3k13127236




        49.3k13127236










        answered Nov 30 at 8:29









        bistoco

        1,014717




        1,014717















            Popular posts from this blog

            Mont Emei

            Province de Neuquén

            Journaliste