Wednesday 3 August 2016

Ubuntu - Swap between PHP 5.5, 5.6 and 7.0

Hello,

This is tutorial how we can do it:
  1. Install PHP 5.5:
    • sudo apt-get install -y php5
  2. Install PHP 5.6:
    • sudo add-apt-repository ppa:ondrej/php
      • In some case, you will need to change Ubuntu codename in this file:
        • sudo vim /etc/apt/sources.list.d/ondrej-ubuntu-php-xenial.list
    •  sudo apt-get update
    • sudo apt-get install -y php5.6
  3. Install PHP 7.0:
    • sudo apt-get install -y php7.0
  4.   Create symlink in your .bashrc file for quick access:
    • vim ~/.bashrc
    • Apache2:
      • #################################################
        ############### PHP Version Toggle ##############
        #################################################
        # Remove the -q to see debugging information if there are problems
        alias enphp5.5="
         sudo a2dismod php5.6 -q;
         sudo a2dismod php7.0 -q;
         sudo a2enmod php5 -q;
         sudo ln -sf /usr/bin/php5 /usr/bin/php;
         sudo service apache2 restart"
        alias enphp5.6="
         sudo a2dismod php5 -q;
         sudo a2dismod php7.0 -q;
         sudo a2enmod php5.6 -q;
         sudo ln -sf /usr/bin/php5.6 /usr/bin/php;
         sudo service apache2 restart"
        alias enphp7.0="
         sudo a2dismod php5 -q;
         sudo a2dismod php5.6 -q;
         sudo a2enmod php7.0 -q;
         sudo ln -sf /usr/bin/php7.0 /usr/bin/php;
         sudo service apache2 restart"
        
    • Nginx:
      • Remove apache2:
        • sudo service apache2 stop
        • sudo apt-get remove apache2*
        • sudo apt-get purge apache2
      • Install php-fpm for all versions
        • sudo apt-get install php5-fpm
        • sudo apt-get install php5.6-fpm
        • sudo apt-get install php7.0-fpm
      • Stop all php-fpm:
        • sudo service php5-fpm stop
        • sudo service php5.6-fpm stop
        • sudo service php7.0-fpm stop
      • #################################################
        ############### PHP Version Toggle ##############
        #################################################
        # Remove the -q to see debugging information if there are problems
        alias enphp5.5="
         sudo ln -sf /usr/bin/php5 /usr/bin/php;
         sudo service php5.6-fpm stop;
         sudo service php7.0-fpm stop;
         sudo service php5-fpm start;
         sudo find /etc/nginx/sites-available -type f -exec sed -i 's,/run/php/php5.6-fpm.sock,/var/run/php5-fpm.sock,g;s,/run/php/php7.0-fpm.sock,/var/run/php5-fpm.sock,g' {} \;
         sudo service nginx restart"
        alias enphp5.6="
         sudo ln -sf /usr/bin/php5.6 /usr/bin/php;
         sudo service php5-fpm stop;
         sudo service php7.0-fpm stop;
         sudo service php5.6-fpm start;
         sudo find /etc/nginx/sites-available -type f -exec sed -i 's,/var/run/php5-fpm.sock,/run/php/php5.6-fpm.sock,g;s,/run/php/php7.0-fpm.sock,/run/php/php5.6-fpm.sock,g' {} \;
         sudo service nginx restart"
        alias enphp7.0="
         sudo ln -sf /usr/bin/php7.0 /usr/bin/php;
         sudo service php5-fpm stop;
         sudo service php5.6-fpm stop;
         sudo service php7.0-fpm start;
         sudo find /etc/nginx/sites-available -type f -exec sed -i 's,/var/run/php5-fpm.sock,/run/php/php7.0-fpm.sock,g;s,/run/php/php5.6-fpm.sock,/run/php/php7.0-fpm.sock,' {} \;
         sudo service nginx restart"
        
  5. Reload your new .bashrc commands:
    • source ~/.bashrc
  6. Done, now you can try it with:
    • enphp5.5
    • php -v
    • enphp5.6
    • php -v
    • enphp7.0
    • php -v

Good luck!
Source: https://github.com/JREAM/phalcon-xenial

1 comment:

  1. You will forgive me, but I fail to rolex replica sale, that given you have already taken the money from my account, and everything has been fully paid, why you need to see my visa card. The replica watches sale is in your account, you took more than you were authorized to do from my VISA Capital One card, so why can't you simply send the replica watches sale to me as they have been fully paid? Whilst I understand that you need to take certain precautions against fraud, I equally have a rolex replica sale with providing my details for the same reasons, and in particular, given that my friend Vic didn't need to provide his card rolex replica sale. As such, I don't want to waste any more of my time, so unless you can't forward the replica watches sale with immediate rolex replica uk, please credit my VISA Capital One credit card with the full amount that is due. I have to say that I am bitterly rolex replica sale with the appalling way I have been treated by your company, and the fact that you took more money from my card than you were rolex replica to do. Can you please email to confirm which action you will take, as I will need to respond accordingly.

    ReplyDelete