skip to Main Content

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

3

Answers


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

    Login or Signup to reply.
  2. 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
    
    Login or Signup to reply.
  3. sudo a2dismod php8.0
    sudo a2dismod php8.1
    sudo a2dismod mpm_prefork php8.0
    sudo a2dismod mpm_event php8.0
    sudo a2dismod mpm_worker php8.0
    sudo a2enmod php8.1
    //I know, it still displays notifications about the conflicts
    sudo systemctl restart apache2
    php -v
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search