Skip to content

Instantly share code, notes, and snippets.

@imanilchaudhari
Created November 20, 2018 05:23

Revisions

  1. imanilchaudhari created this gist Nov 20, 2018.
    39 changes: 39 additions & 0 deletions PHP Version Manager On Ubuntu 18.04
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    Get the information of PHP
    ==========================
    $ sudo apt show php
    OR
    $ sudo apt show php -a


    $ sudo apt install php // this will install default php version ( may be 7.2 )

    T0 Install Different Versions Of PHP
    ====================================
    $ sudo apt install python-software-properties
    $ sudo add-apt-repository ppa:ondrej/php

    $ sudo apt-get update

    For Apache
    ==========
    $ sudo apt install php5.6 [PHP 5.6]
    $ sudo apt install php7.2 [PHP 7.2]

    For Nginx
    =========
    $ sudo apt install php5.6-fpm [PHP 5.6]
    $ sudo apt install php7.2-fpm [PHP 7.2]

    To Install Required Modules
    ===========================
    $ sudo apt install php5.6-cli php5.6-xml php5.6-mysql ...
    $ sudo apt install php7.2-cli php7.2-xml php7.2-mysql ...

    Set Default PHP Version in Ubuntu (i.e. from 7.2 to 5.6)
    ========================================================
    $ sudo update-alternatives --set php /usr/bin/php5.6
    $ sudo a2dismod php7.2
    $ sudo a2enmod php5.6
    $ sudo systemctl restart apache2

    And so on