How to Safely Downgrade from PHP 7.4 to PHP 7.3 on Ubuntu 20 LTS
Good Day Pare, In this tutorial, I'll teach you how to downgrade your PHP 7.4 to PHP 7.3 on your Ubuntu 20.04 LTS safely. For this, we will use different commands such sudo, apt-get, a2dismod, and a2endmond which we will explain along the road.
This tutorial can be use for downgrading your PHP 7.3 to PHP 7.2 and so on and so forth.
Why do you really need to downgrade?
- Some functionality of our laravel application is not working properly such as pdf for WKHTMLTOPDF.
- It's either one of your PHP functions or method is not yet supported and needs some additional testing before upgrading again.
- You messed up your server production. 😅 😅 😅
Step 1.
Login to your ubuntu server using your favorite shell command applications, for now i'm using my iTerm app on mac.
Then type this command as a sudo user.
sudo add-apt-repository ppa:ondrej/php
Then run a apt-get update
which tells APT to update its database based on the available packages that can be installed in your ubuntu
sudo apt-get update
Step 2.
Once the update is finish, we will install our PHP 7.3 in our ubuntu.
sudo apt-get install php7.3
After the installing the php 7.3 version we will now install some of the modules needed for our project. Ex. if we are working with laravel you should install these modules.
sudo apt-get install php7.3-cli php7.3-common php7.3-json php7.3-opcache php7.3-mysql php7.3-mbstring php7.3-zip php7.3-fpm php7.3-intl php7.3-simplexml php7.3-bcmath php7.3-dev
Step 3.
The next thing, we should do is to disable the installed PHP 7.4 using a2dismod.
sudo a2dismod php7.4
We can now enable our php 7.3 using a2enmod.
sudo a2enmod php7.3
If you are using apache2 you can restart it using this command
sudo service apache2 restart
Or, if you're using nginx
sudo service nginx restart
Step 4.
Finally to reflect your php 7.3 in your bash terminal just run these command below.
sudo update-alternatives --set php /usr/bin/php7.3
sudo update-alternatives --set phar /usr/bin/phar7.3
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.3
sudo update-alternatives --set phpize /usr/bin/phpize7.3
sudo update-alternatives --set php-config /usr/bin/php-config7.3
TIPS:
Make sure to check your apache2 and nginx web server configuration if you're using php-fpm. It might be pointed out to your old php-fpm proxy socket.
Just change the version of your current php that was installed, it will look like this for nginx:
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
And We're Done Folks.
Next Featured
How To Reset MySQL 5.7 Root Password In Centos Or Ubuntu
Have you forgotten your MySQL root password? If yes, then in this article we will discuss on how to reset MySQL root password in centos or ubuntu in a few steps.
Voila!!!
I hope you enjoy our tutorial, Let me know incase you encounter any error I would love to answer that. Don't forget to subscribe to my Youtube Channel at Let's Code Pare - Youtube Channel
