I install vesta control panel on my ubuntu EC2 instance on AWS. By default vesta uses php 7.3 but my script demands php 5.6. So i had to downgrade my php version from and followed below method:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php5.6
php -v
--This may show your old version.
--So now to switching the versions 7.0 > 5.6
sudo a2dismod php7.0
sudo a2enmod php5.6
sudo service apache2 restart
sudo update-alternatives --set php /usr/bin/php5.6
--Basically need to install few modules first
sudo apt-get install php5.6-mysql php-gettext php5.6-mbstring php-xdebug libapache2-mod-php5.6
--enabling your required extensions example >>> sudo phpenmod mbstring
sudo apt-get update
sudo update-alternatives --set php /usr/bin/php5.6
sudo service apache2 restart
https://forum.vestacp.com/viewtopic.php?t=6898
After PHP 5.6 is running fine but my phpmyadmin is showing blank page. I tried many online solutions but i couldn't resolve it.
Related
I am using linux Ubuntu 18.04
And I wanna revert back to the previous version of PHP.
I've seen tutorials that requires me to uninstall the latest version, now I am asking if there is a workaround in this problem such that I can easily switch from using 7.2 or 7.4.
I have faced the same problem and Here is the solution:
sudo update-alternatives --config php
Now select which version U want on right now, thanks
Yes, you can.
1- To stop running PHP 7.4, run the commands below to disable it for Apache2:
sudo a2dismod php7.4
2- Then run the commands below to enable PHP 7.2 for Apache2 to use:
sudo a2enmod php7.2
3- Restart Apache2 for the changes to apply by running the commands below:
sudo systemctl restart apache2.service
Downgrade from 7.4 to 7.2
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2
sudo apt-get install php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-mysql php7.2-mbstring php7.2-zip php7.2-fpm php7.2-intl php7.2-simplexml
sudo a2dismod php7.4
sudo a2enmod php7.2
sudo service apache2 restart
sudo update-alternatives --set php /usr/bin/php7.2
sudo update-alternatives --set phar /usr/bin/phar7.2
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.2
sudo update-alternatives --set phpize /usr/bin/phpize7.2
sudo update-alternatives --set php-config /usr/bin/php-config7.2
You can install multiple php version in ubuntu and can disable the version you don't need e.g:
sudo a2dismod php7.4
sudo a2enmod php7.2
If you nginx user. first install php 7.4 all necessary item.
sudo apt-get update
sudo apt -y install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.4-cli php7.4-json php7.4-common php7.4-mysql php7.4-zip php7.4-gd php7.4-mbstring php7.4-curl php7.4-xml php7.4-bcmath php7.4-fpm -y
systemctl status php7.2-fpm.service #get previous version id
kill -9 873 #id will be replace with your php.7.2-fpm
service php7.4-fpm restart
systemctl status php7.4-fpm.service #check php status
Done, All okay
We downgrade or upgrade the PHP version using the following steps.
Let me show how to downgrade (from 7.2 >> 7.0 )
step1: sudo a2dismod php7.2
step2: sudo a2enmod php7.0
step3: sudo systemctl restart apache2
step4: sudo update-alternatives --set php /usr/bin/php7.0
That's it, version changed to 7.2 as you can see below.
For some reason, my php cli switched to 5.6.40 instead of the 7.2 version that I had before. Then I was unable to restart apache2, so I tried to apt purge php7 & php5 to reinstall them.
But now, I only have this error:
(sorry for the French, it says packages have unsatisfied dependencies). How can I clean it ?
I have already tried the following commands :
apt-get -f install
apt-get clean
apt-get update
apt-get upgrade
You have to purge comlete php7.3:
sudo apt-get remove -y --purge php7.3*
add repository (if not exist):
sudo add-apt-repository ppa:ondrej/php
install dependents
sudo apt install php libapache2-mod-php
if you have apache:
sudo systemctl restart apache2
if you have nginx:
sudo service nginx restart
install php:
sudo apt install php-fpm
check php:
sudo service php7.3-fpm status
I installed Laravel 5.6, but it's not working because it requires PHP 7.2.
I use Ubuntu 17, and installed Apache 2 and PHP 7.2 (7.1, 7.0) but when I use phpinfo() it shows php7.0.
So how can I config Apache and set php7.2 instead of php7.0?
At first you have to install php7.2 with the following commands
sudo apt install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install -y php7.2
sudo apt install libapache2-mod-php7.2 php7.2-cli php7.2-curl php7.2-intl php7.2-mysql php7.2-opcache php7.2-json php7.2-bz2 php7.2-mcrypt php7.2-xmlrpc php7.2-mbstring php7.2-soap php7.2-xml php7.2-zip
After installing php you have to run the following commands:
sudo update-alternatives --set php "/usr/bin/php7.2";
sudo update-alternatives --set "php-config" "/usr/bin/php-config7.2";
sudo a2dismod "php7.0"
sudo a2dismod "php5.6"
sudo a2enmod "php7.2"
sudo service apache2 restart
If you installed php7.2-dev then you should run the following command too:
sudo update-alternatives --set "phpize" "/usr/bin/phpize7.2";
Run the following commands to have PHP 7.2 installed
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2-cli
After that, you can run the command below to see the installed version of PHP:
php -v
I have a problem with phpmyadmin on ubuntu 16.04 after upgrading php 5.6 to php 7 by this way:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0 php5.6 php5.6-mysql php-gettext php5.6-mbstring php-mbstring php7.0-mbstring php-xdebug libapache2-mod-php5.6 libapache2-mod-php7.0
after this command :
sudo a2dismod php5.6 ; sudo a2enmod php7.0 ; sudo service apache2 restart
phpMyadmin has error :
The mysqli extension is missing. Please check your PHP configuration.
But it does not have error on php5.
I want use phpMyadmin on php7.
Can anyone help me?
You need to do following steps.
php --version
Check your php version and run following command.
sudo apt-get install php5.6-mysql
In my case my version of php is 5.6, you may have different. Replace your version and hit enter.
After installing just run
sudo service apache2 restart
Hope it will help
You first need to install php7 , then install php5.
Completely remove your php and phpmyadmin :
sudo dpkg -P phpmyadmin
sudo rm -f /etc/apache2/conf.d/phpmyadmin.conf
sudo service apache2 restart
sudo apt-get purge php.*
sudo service apache2 restart
Install php7 and php7.0-mysql and ... : https://askubuntu.com/a/705893/424146
Install phpmyadmin (on php7) : install phpmyadmin with lamp stack on ubuntu 16.04
Run these commands again to install php5.6 beside your php7:
Install php5.6 beside php7 : (I got help from this link)
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0 php5.6 php5.6-mysql php-gettext php5.6-mbstring php-mbstring php7.0-mbstring php-xdebug libapache2-mod-php5.6 libapache2-mod-php7.0
sudo service apache2 restart
Switch PHP version:
From php5.6 to php7.0 :
sudo a2dismod php5.6 ; sudo a2enmod php7.0 ; sudo service apache2 restart
From php7.0 to php5.6 :
sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart
Reinstall or Reconfigure PHPMyAdmin. The following worked for me:
dpkg-reconfigure phpmyadmin
Solution for Windows PC
Try to check to check your httpd-xampp config file.
Make sure the Make sure the Php-Module conform with your current php version.
example here: IfModule php5_module
Based on your migration you are using php7, so edit all the php5_module tag in your config file to php7_module and restart the apache server.
I have install LAMP stack on ubuntu 16, I got php 7.
I want to downgrade it to php 5.4 . what command should I use to remove php 7 and install php 5.4 in my ubuntu 16?
try this
sudo apt-get purge php*
then
sudo apt-get install php5.4 php5.4-gettext php5.4-common
First, remove LAMP from your Ubuntu.
Then, use the following:
sudo apt-get update
sudo apt-get install apache2 php5 mysql-server mysql-client php5-mysql //install php 5.3
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php5
sudo apt-get remove php5 //remove php 5.3
sudo apt-get update
sudo apt-get install php5 //install php 5.4
First you must install PHP 5.4 (if you have not already done so):
sudo apt-get install php5-fpm php5-mysql
And then:
Apache:
sudo a2dismod php7.0 ; sudo a2enmod php5.4 ; sudo service apache2 restart
CLI:
sudo update-alternatives --set php /usr/bin/php5.4