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.
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!
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.
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:
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:
Then, install PHP 8.1 (replace “8.1” with “8.2” if you want to install PHP 8.2):
You may need to install additional PHP modules based on your application requirement. For example, to install commonly used PHP modules:
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:
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:
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