Upgrading PHP to version 8.2 on Debian Linux
January 16, 2023debian laravel
Today I decided to upgrade my PHP version to 8.2 on my local Debian desktop to test compatability with Laravel versions 8 and 9 and soon to be version 10 of laravel!
I wrote a blog previously about upgrading to PHP 8.0 and also using ansible to upgrade to PHP version 8.1 only a few months back.
Today I decided to upgrade to PHP 8.2 and it was a fairly similar and simple process. Using this
apt install to install a comprenhsive set of PHP modules to fulfil the requirements of Laravel, this should cover most peoples needs.
sudo apt install php8.2-cli php8.2-curl php8.2-mysqlnd php8.2-gd php8.2-opcache php8.2-zip php8.2-intl php8.2-common php8.2-bcmath php8.2-imap php8.2-imagick php8.2-xmlrpc php8.2-readline php8.2-memcached php8.2-redis php8.2-mbstring php8.2-apcu php8.2-xml php8.2-xml php8.2-redis php8.2-memcached php8.2-memcache php8.2 php8.2-fpm php8.2-cli php8.2-fpm php8.2-common libapache2-mod-fcgid php8.2-cli php8.2-bz2 php8.2-tidy libapache2-mod-php8.2 php8.2-fpm -y
To activate the new version (or select an older version) the command 'update-alternatives' can be used thus:
sudo update-alternatives --config php
which provides a menu of versions like so:
There are 5 choices for the alternative php (providing /usr/bin/php). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/bin/php.default 100 auto mode 1 /usr/bin/php.default 100 manual mode 2 /usr/bin/php7.4 74 manual mode 3 /usr/bin/php8.0 80 manual mode * 4 /usr/bin/php8.1 81 manual mode 5 /usr/bin/php8.2 82 manual mode Press <enter> to keep the current choice[*], or type selection number: 5
I have kept the older versions for now and to setup Apache to use the new version, these commands update the Apache config (this is for both the fpm and apache module)
sudo a2enconf php8.2-fpm sudo a2disconf php8.1-fpm sudo a2enmod php8.2 sudo a2dismod php8.1 sudo service apache2 restart
And with the apache restart, I am using the latest and greatest version of PHP!
Now to test that my apps work and see what new error messages have been added.
If you would like to contact me you can either use this form on londinium.com or via Twitter @andylondon