How to switch between PHP versions on Ubuntu Nginx





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















I have PHP 7.0 and 7.2 installed.



For now, I use PHP 7.0.



How can I switch to PHP 7.2?










share|improve this question





























    1















    I have PHP 7.0 and 7.2 installed.



    For now, I use PHP 7.0.



    How can I switch to PHP 7.2?










    share|improve this question

























      1












      1








      1








      I have PHP 7.0 and 7.2 installed.



      For now, I use PHP 7.0.



      How can I switch to PHP 7.2?










      share|improve this question














      I have PHP 7.0 and 7.2 installed.



      For now, I use PHP 7.0.



      How can I switch to PHP 7.2?







      php-7 nginx ubuntu






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      RufusRufus

      1468




      1468






















          3 Answers
          3






          active

          oldest

          votes


















          1














          For Nginx, we simply need to update the PHP-FPM socket in its configuration file. But before that make sure that the PHP-FPM is installed for your version and is running as a service.



          Take a backup of the default configuration file and then open it up in your favourite text editor.



          $ cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak
          $ sudo vim /etc/nginx/sites-available/default


          Change the FastCGI backend to use the new PHP-FPM socket, save and exit the file



          location ~ .php$ {
          include snippets/fastcgi-php.conf;
          fastcgi_pass unix:/run/php/php7.2-fpm.sock;
          }


          Run the configuration test



          $ nginx -t


          Restart the web server



          $ sudo service nginx restart


          For more information visit here






          share|improve this answer































            1














            Please use to below command



            sudo update-alternatives --config php


            After run above command select the PHP version that you need to use.




            Press to keep the current choice[*], or type selection number: For example 2




            After switching below command used to restart the PHP and Nginx server.



            sudo service nginx restart
            sudo service php7.1-fpm or php7.2-fpm restart


            Please try above code. If you have any help let me know.






            share|improve this answer

































              1














              sudo a2dismod php7.0<br>
              sudo a2enmod php7.2<br>
              sudo systemctl restart apache2


              Reference: Link






              share|improve this answer


























              • nginx? not apache

                – Prathap Gunasekaran
                7 mins ago












              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "479"
              };
              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%2fmagento.stackexchange.com%2fquestions%2f272815%2fhow-to-switch-between-php-versions-on-ubuntu-nginx%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              For Nginx, we simply need to update the PHP-FPM socket in its configuration file. But before that make sure that the PHP-FPM is installed for your version and is running as a service.



              Take a backup of the default configuration file and then open it up in your favourite text editor.



              $ cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak
              $ sudo vim /etc/nginx/sites-available/default


              Change the FastCGI backend to use the new PHP-FPM socket, save and exit the file



              location ~ .php$ {
              include snippets/fastcgi-php.conf;
              fastcgi_pass unix:/run/php/php7.2-fpm.sock;
              }


              Run the configuration test



              $ nginx -t


              Restart the web server



              $ sudo service nginx restart


              For more information visit here






              share|improve this answer




























                1














                For Nginx, we simply need to update the PHP-FPM socket in its configuration file. But before that make sure that the PHP-FPM is installed for your version and is running as a service.



                Take a backup of the default configuration file and then open it up in your favourite text editor.



                $ cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak
                $ sudo vim /etc/nginx/sites-available/default


                Change the FastCGI backend to use the new PHP-FPM socket, save and exit the file



                location ~ .php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.2-fpm.sock;
                }


                Run the configuration test



                $ nginx -t


                Restart the web server



                $ sudo service nginx restart


                For more information visit here






                share|improve this answer


























                  1












                  1








                  1







                  For Nginx, we simply need to update the PHP-FPM socket in its configuration file. But before that make sure that the PHP-FPM is installed for your version and is running as a service.



                  Take a backup of the default configuration file and then open it up in your favourite text editor.



                  $ cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak
                  $ sudo vim /etc/nginx/sites-available/default


                  Change the FastCGI backend to use the new PHP-FPM socket, save and exit the file



                  location ~ .php$ {
                  include snippets/fastcgi-php.conf;
                  fastcgi_pass unix:/run/php/php7.2-fpm.sock;
                  }


                  Run the configuration test



                  $ nginx -t


                  Restart the web server



                  $ sudo service nginx restart


                  For more information visit here






                  share|improve this answer













                  For Nginx, we simply need to update the PHP-FPM socket in its configuration file. But before that make sure that the PHP-FPM is installed for your version and is running as a service.



                  Take a backup of the default configuration file and then open it up in your favourite text editor.



                  $ cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak
                  $ sudo vim /etc/nginx/sites-available/default


                  Change the FastCGI backend to use the new PHP-FPM socket, save and exit the file



                  location ~ .php$ {
                  include snippets/fastcgi-php.conf;
                  fastcgi_pass unix:/run/php/php7.2-fpm.sock;
                  }


                  Run the configuration test



                  $ nginx -t


                  Restart the web server



                  $ sudo service nginx restart


                  For more information visit here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 52 mins ago









                  Prathap GunasekaranPrathap Gunasekaran

                  2,1191619




                  2,1191619

























                      1














                      Please use to below command



                      sudo update-alternatives --config php


                      After run above command select the PHP version that you need to use.




                      Press to keep the current choice[*], or type selection number: For example 2




                      After switching below command used to restart the PHP and Nginx server.



                      sudo service nginx restart
                      sudo service php7.1-fpm or php7.2-fpm restart


                      Please try above code. If you have any help let me know.






                      share|improve this answer






























                        1














                        Please use to below command



                        sudo update-alternatives --config php


                        After run above command select the PHP version that you need to use.




                        Press to keep the current choice[*], or type selection number: For example 2




                        After switching below command used to restart the PHP and Nginx server.



                        sudo service nginx restart
                        sudo service php7.1-fpm or php7.2-fpm restart


                        Please try above code. If you have any help let me know.






                        share|improve this answer




























                          1












                          1








                          1







                          Please use to below command



                          sudo update-alternatives --config php


                          After run above command select the PHP version that you need to use.




                          Press to keep the current choice[*], or type selection number: For example 2




                          After switching below command used to restart the PHP and Nginx server.



                          sudo service nginx restart
                          sudo service php7.1-fpm or php7.2-fpm restart


                          Please try above code. If you have any help let me know.






                          share|improve this answer















                          Please use to below command



                          sudo update-alternatives --config php


                          After run above command select the PHP version that you need to use.




                          Press to keep the current choice[*], or type selection number: For example 2




                          After switching below command used to restart the PHP and Nginx server.



                          sudo service nginx restart
                          sudo service php7.1-fpm or php7.2-fpm restart


                          Please try above code. If you have any help let me know.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 50 mins ago

























                          answered 55 mins ago









                          Kamlesh SolankiKamlesh Solanki

                          25416




                          25416























                              1














                              sudo a2dismod php7.0<br>
                              sudo a2enmod php7.2<br>
                              sudo systemctl restart apache2


                              Reference: Link






                              share|improve this answer


























                              • nginx? not apache

                                – Prathap Gunasekaran
                                7 mins ago
















                              1














                              sudo a2dismod php7.0<br>
                              sudo a2enmod php7.2<br>
                              sudo systemctl restart apache2


                              Reference: Link






                              share|improve this answer


























                              • nginx? not apache

                                – Prathap Gunasekaran
                                7 mins ago














                              1












                              1








                              1







                              sudo a2dismod php7.0<br>
                              sudo a2enmod php7.2<br>
                              sudo systemctl restart apache2


                              Reference: Link






                              share|improve this answer















                              sudo a2dismod php7.0<br>
                              sudo a2enmod php7.2<br>
                              sudo systemctl restart apache2


                              Reference: Link







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited 18 mins ago









                              Rakesh Donga

                              2,716317




                              2,716317










                              answered 28 mins ago









                              Hafiz ArslanHafiz Arslan

                              17512




                              17512













                              • nginx? not apache

                                – Prathap Gunasekaran
                                7 mins ago



















                              • nginx? not apache

                                – Prathap Gunasekaran
                                7 mins ago

















                              nginx? not apache

                              – Prathap Gunasekaran
                              7 mins ago





                              nginx? not apache

                              – Prathap Gunasekaran
                              7 mins ago


















                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Magento 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%2fmagento.stackexchange.com%2fquestions%2f272815%2fhow-to-switch-between-php-versions-on-ubuntu-nginx%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

                              Ponta tanko

                              Tantalo (mitologio)

                              Erzsébet Schaár