enter image description here

I have magento 2.4.6 installed on my server and running php 8.1.18. (upgraded from 2.4.3)
when I open the main page, I'm getting this message :

enter image description here

Can anyone help me how to fix this? Thank you.

  • you need to globally set the PHP version to 8.1. to check the global version. print the phpinfo inside the browser.prnt.sc/dnC7_wWt9vwI May 11, 2023 at 5:03
  • thank you for your reply. the phpinfo() shows that I'm using php version 8.1.18. my previous php version was 7.4 before i upgrade magento 2.4.3 to 2.4.6 using composer. is there any configuration I'm missing?
    – user9814
    May 11, 2023 at 13:52
  • kindly disable the php7.4 version and restart the apache2. there seems to be nothing wrong with the Magento project you just need to check the PHP configuration. May 11, 2023 at 14:50

8 Answers 8


There is something wrong with your php version,

For more details please print phpinfo and provide more details regarding your problem.


you can install the php you need and use the command sudo update-alternatives --config php to choose the one that will serve you.


To solve this issue you need to check the

  1. Check server PHP version (8.x). (Nginx server hosts PHP version should be 8.x)
  2. Check Command line PHP Version (8.x).
  1. Clear the Magento cache: Sometimes, cached configurations can cause issues. Clear the Magento cache by running the following command from your Magento root directory:

    php bin/magento cache:clean
  2. Check PHP version: Verify that PHP 8.1 is indeed the version running on your server. You can do this by executing the following command:

    php -v
  3. Check PHP version for the webserver: Confirm that your webserver (e.g., Apache or Nginx) is also using PHP 8.1. Sometimes, the webserver might be running a different version of PHP, causing conflicts. Restart the webserver to apply any changes you made to the PHP configuration.

  4. Verify PHP configuration for the webserver: Ensure that your webserver's configuration is correctly pointing to PHP 8.1. Check the virtual host or server block configuration file for your Magento installation and verify that it specifies the correct PHP version.

  5. Confirm PHP settings in the .htaccess file: In the Magento root directory, check the .htaccess file and verify that it doesn't override the PHP version settings. Look for any lines containing php_value or php_flag and remove or modify them if necessary.

  6. Check Magento configuration files: Open the app/etc/env.php file and verify that the php_version value is set correctly. It should be set to php_version' => '7.4.27' for Magento 2.4.6. If it is set to an older version, update it accordingly.

  7. Reinstall or recompile dependencies: If the issue persists, there might be a problem with the dependencies or vendor files. Try reinstalling the Magento dependencies by running the following commands from the Magento root directory:

    composer install
    php bin/magento setup:upgrade


As per my understanding you have updated only the PHP CLI version. Please create any phpinfo.php file and check your PHP version on frontend.

You can change your PHP version for both sides by below steps.

Set PHP version for CLI

sudo update-alternatives --set php /usr/bin/php8.1

Disable PHP version 7.4

sudo a2dismod php7.4

Enable PHP version 8.1

sudo a2enmod php8.1

Restart the Apache server

sudo systemctl restart apache2

I hope it'll help



May be just chnaged CLI Version also need to change Script PHP Version

sudo nano /etc/nginx/sites-available/default:

upstream fastcgi_backend {
        #server unix:/run/php/php8.2-fpm.sock;
        server unix:/run/php/php8.1-fpm.sock;
        #server unix:/run/php/php7.4-fpm.sock;
        #server unix:/run/php/php7.3-fpm.sock;
        #server unix:/run/php/php7.2-fpm.sock;

Check Magento 2 exception logs. You should find valuable information there.

There could be some extension missing like: sodium or iconv

Also, for Litespeed web server, don't forget to restart detach processes.


You should check the PHP version first, or maybe you are missing any PHP extension and install the PHP FPM.


  • Check the composer version.

  • Check the permissions for the PHP 8.1 FPM.

  • Check the Nginx hosts PHP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.