Home > OS >  PHP version in phpinfo() does not match version active on ubuntu server
PHP version in phpinfo() does not match version active on ubuntu server

Time:02-19

I updated my php version to 8.1, and inside /etc/php I have two directories: 8.0 and 8.1 - I'm not sure if and how I should get rid of 8.0?

Yet mi biggest concern is, that sudo php -v does return as expected:

PHP 8.1.2 (cli) (built: Jan 24 2022 10:42:33) (NTS)

However if I use phpinfo() in my script, it returns PHP Version 8.0.15. What am I missing? What should I do in order to use current PHP version in my scripts?

EDIT:

sudo a2dismod php8.0 gives Module php8.0 already disabled, while sudo a2enmod php8.1 returns:

Considering dependency mpm_prefork for php8.1:
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
Module mpm_prefork already enabled
Considering conflict php5 for php8.1:
Module php8.1 already enabled

CodePudding user response:

You need to reconfigure your Apache server to use the PHP version you want. Check the loaded Apache configuration files, e.g httpd.conf or your OS specific one.

You need to tell Apache web server to use the PHP 8.1 version you installed.

If you use Debian or similar OS you can disable the old PHP module and enable the new PHP module using the following command.

sudo a2dismod php8.0
sudo a2enmod php8.1

CodePudding user response:

As documented in this answer if you stop and restart apache it will load the latest PHP version from disk.

  • Related