WordPress Install sees PHP 7.0.x but Server says PHP 8.1 installed - how to connect things correctly?

Hello all, I hope you can help. I’ve updated PHP on my droplet (LAMP 16.04) and when I do php -v, it tells me PHP 8.1. But my WordPress install is still seeing PHP 7.0.x. I added phpinfo.php and that ALSO says PHP 7.0.x

How can I make sure that the latest PHP version is the one used? I looked at several tutorials and questions answered and I somehow am not finding the right answer. I tried a couple things and I seem to have munted the droplet, so currently running a restore from yesterday’s backup.

Any assistance would be greatly appreciated.

Submit an answer
Answer a question...

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.

Site Moderator
Site Moderator badge
May 4, 2022

Hi @vavroom,

I’ll give you the steps required from the the installation of the PHP version to enabling it

  • Update your repositories:
sudo apt update
  • Install PHP 8.1 along with all of the required PHP modules:
sudo apt install php8.1 php8.1-cli php8.1-mysql php8.1-curl php8.1-gd php8.1-mbstring php8.1-xml php8.1-xmlrpc php8.1-soap php8.1-intl php8.1-zip libapache2-mod-php8.1 php8.1-common php8.1-json php8.1-opcache php8.1-readline
  • Disable the PHP 7.0 Apache2 module:
a2dismod php7.0
  • Enable the PHP 8.1 Apache module:
a2enmod php8.1 
  • Finally, restart Apache so it could load the new PHP 8.1 module:
systemctl restart apache2