How to Change Default PHP Version on Ubuntu

Switch to PHP 8.2

Run the following command to disable Apache module for other PHP versions

sudo a2dismod php* 

Now, enable PHP 8.1 module in Apache server.

sudo a2enmod php8.2 
sudo systemctl restart apache2 

For Command Line Interface:

sudo update-alternatives --set php /usr/bin/php8.2 
sudo update-alternatives --set phar /usr/bin/phar8.2 
sudo update-alternatives --set phar.phar /usr/bin/phar.phar8.2 
sudo update-alternatives --set phpize /usr/bin/phpize8.2 
sudo update-alternatives --set php-config /usr/bin/php-config8.2 

If you want a different version (eg: PHP 8.1 or PHP 8.0) to be configured as default, just replace 8.2 with the required version.


Deprecated: File Theme without comments.php is deprecated since version 3.0.0 with no alternative available. Please include a comments.php template in your theme. in /home/syrsocco/public_html/wp-includes/functions.php on line 6131

Leave a Reply

Your email address will not be published. Required fields are marked *