Question

Droplet console shows php 8.2 and phpinfo functions is showing php 8.0 in browser

I’m trying to run a sage theme on my Wordpress site which requires at least PHP version 8.1.0. When I check php version in droplet console, it shows php version 8.2.6. But when I run phpinfo() function, it shows php version as 8.0.22 in the browser. This is causing my site to break when I activate sage theme on my site. How should I go about making the Wordpress site to run on php 8.1 or above?

When I run phpinfo() function, the ‘Loaded Configuration File’ is ‘/etc/php/8.0/apache2/php.ini’

Now there are 2 other php ini files as well in this directory - ‘/etc/php/’. These are php 8.1 and php 8.2 ini files.

Now I’m not sure how should I go about loading php 8.1 ini file instead of php 8.0 ini file.

The droplet is using Ubuntu 22.04

Thanks in advance for any help on this.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
May 14, 2023

Hi there,

This usually happens when you have installed multiple versions of PHP on your server.

Here’s a step by step guide on how you can switch to PHP 8.1 or above for your Apache web server:

Step 1: Check Available PHP versions

First, verify the installed PHP versions on your server. Run the following command:

ls /etc/php/

This should list out all the installed PHP versions. If PHP 8.1 or above is not listed, you need to install it.

Step 2: Install PHP 8.1 or above (if not installed)

To install PHP 8.1 or above, you can use the following commands:

First, update the package lists for upgrades and new package installations:

sudo apt-get update

Then, install PHP 8.1 (replace “8.1” with “8.2” if you want to install PHP 8.2):

sudo apt-get install php8.1 php8.1-cli php8.1-common

You may need to install additional PHP modules based on your application requirement. For example, to install commonly used PHP modules:

sudo apt-get install php8.1-mysql php8.1-soap php8.1-bcmath php8.1-xml php8.1-mbstring php8.1-gd php8.1-curl

Step 3: Disable PHP 8.0 module and Enable PHP 8.1 or above module

You will need to disable the PHP 8.0 Apache module and enable the PHP 8.1 (or 8.2) Apache module. You can do this with the following commands:

sudo a2dismod php8.0
sudo a2enmod php8.1

Replace “8.1” with “8.2” if you want to enable PHP 8.2.

Step 4: Restart Apache

Finally, you need to restart your Apache server for changes to take effect:

sudo systemctl restart apache2

Step 5: Verify the PHP version

After this, if you run the phpinfo() function, it should now display PHP 8.1 (or 8.2) as your current PHP version. If it still shows the old version, you may need to clear your browser cache or check your PHP configurations again.

Remember, some WordPress plugins may not be compatible with PHP 8.1 or 8.2, so be sure to verify that all your plugins are working properly after switching PHP versions.

Also make sure to always take a backup of you Droplet before doing any major upgrades. That way you can revert back to a working version if needed.

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel