5.02 to 6.0 Upgrade Issue

I’m going to add to and maybe repeat what some have said here about PHP versions. Here are some concepts that took me a minute to figure out so I hope I can help you and future readers avoid heartache when dealing with versions.

First, there are “two” php’s when it comes to your server. There is the CLI (Command Line Interface) version and the version that runs your browser. It is possible to be running PHP 8.0 on the CLI and also be running PHP 5.6 on your web browser. You need to check both versions based on what you are trying to get done.

To get the version that your CLI is running, in the command prompt type “php -v”. You should see something like this:

To see the version that your web browser is running, create a new file in your html directory and put “phpinfo()” as the only line. After you are done remove this file because it has a lot of information about your server that you do not want public.

When I use Jerry’s instructions to change my php version (Remember, you must restart apache server after making these changes!)

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

my phpinfo() page shows the following:

but from my command line the CLI version is still php 7.4:

If I want to change the CLI version you must use the “update-alternatives --set php /usr/bin/phpx.x” to get the change. Such as so:

$ sudo update-alternatives --set php /usr/bin/php8.0
$ sudo update-alternatives --set phar /usr/bin/phar8.0
$ sudo update-alternatives --set phar.phar /usr/bin/phar.phar8.0

In the following screenshot I use the update-alternatives and at the end I use php -v to show the new CLI version:

And remember, always restart apache for the changes to take affect

1 Like