Recently my Ubuntu server updated itself, and I suddenly had version PHP 8.0 on my terminal.
I use PHP for composer installations, and some packages in my composer.json required PHP 7.4 and wouldn’t install with PHP 8.
So I had to downgrade my PHP Version from PHP 8.0 to PHP 7.4
This is done like that:
sudo a2dismod php8.0
sudo a2enmod php7.4
sudo service apache2 restart
sudo update-alternatives –set php /usr/bin/php7.4
sudo update-alternatives –set phar /usr/bin/phar7.4
sudo update-alternatives –set phar.phar /usr/bin/phar.phar7.4
sudo update-alternatives –set phpize /usr/bin/phpize7.4
sudo update-alternatives –set php-config /usr/bin/php-config7.4
Not every command is neccessary, but it won’t hurt to list and execute them all. You can just copy&paste these 8 lines into your bash.
And now we are running PHP 7.4 again and can install our composer dependencies:
$ php -v
PHP 7.4.16 (cli) (built: Mar 5 2021 07:54:02) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.16, Copyright (c), by Zend Technologies
If you get messages about missing raphf or propro modules, do:
sudo pecl install raphf
sudo pecl install propro
After this, you need to add these modules to your php.ini config.
1. find your php.ini
$ php -i | grep php.ini
Configuration File (php.ini) Path => /etc/php/7.4/cli
Loaded Configuration File => /etc/php/7.4/cli/php.ini
Add these 2 lines to your php.ini, preferably to the block with the extensions:
… snip …
; The MIBS data available in the PHP distribution must be installed.
… snip …