//In ubunutu
Default PHP 7.1 is set on your system and you need to switch to PHP 5.6
$ sudo a2dismod php7.1
$ sudo a2enmod php5.6
$ sudo service apache2 restart
sudo update-alternatives --set php /usr/bin/php5.6
# This might be a longer process but it worked for me
# firstly completely remove the current PHP present in your OS (ubuntu)
# command to remove > sudo apt-get purge php7.*
# next command > sudo apt autoremove -y
# now install the php version you want with the command > sudo apt-get install php7.2 libapache2-mod-php7.2 php7.2-mcrypt php7.2-mysql
alias setphp="sudo update-alternatives --config php;sudo update-alternatives --config phar; update-alternatives --config phar.phar; a2dismod php*.*;systemctl restart apache2"
Put the above alias in the
sudo nano ~/.bashrc
#After the above command just run this command
a2enmod php<Your Desired Version> # like, a2enmod php7.4
Now you can run command "setphp" from your terminal.
alias setphp="sudo update-alternatives --config php;sudo update-alternatives --config phar; update-alternatives --config phar.phar; a2dismod php*.*;systemctl restart apache2"
Put the above alias in the
sudo nano ~/.bashrc
#After the above command just run this command
a2enmod php<Your Desired Version> # like, a2enmod php7.4
Now you can run command "setphp" from your terminal.