creative dark internet designer

How to Switch between Multiple PHP Version on Ubuntu TERMINAL?


Recently my phpmyadmin was not running. Even after the installation of MySQL native driver mysqlnd I get this error which says:

The mysqli extension is missing. Please check your PHP configuration. See our documentation for more information.

I have noted the list of commands I used to install mysqlnd in this blog:

But the issue doesn’t get solved even after installing the plugin. Actually here the issue is not about the installation of plugins. This is an issue caused by the mismatch of PHP versions. I’ve different versions of PHP installed on my machine. Since I use Laravel it has PHP version 7 and above. And when I manually install php it downloads and installs the latest one which is PHP 8.0.14( Updated on Dec, 2021)

How to Switch between Multiple PHP Version on Ubuntu?

After I switched from my older version of PHP7 to PHP 8 my localhost/phpmyadmin was working. I logged in to my MySQL database afterward. The easier way of solving the error was to disable previous versions of PHP and enable the latest one. To do so type the following command on your terminal:

Switch From PHP 7.4 => PHP 8.0

sudo a2dismod php7.4
sudo a2enmod php8.0
sudo service apache2 restart

Switch From PHP 7.4 => PHP 5.6

sudo a2dismod php7.4
sudo a2enmod php5.6
sudo service apache2 restart

Now try: http://localhost/phpmyadmin this should display the login screen for mysql database.