Fix incorrect PHP handler or session path

 

Server software and configuration can vary from provider to provider, which in turn causes differences in PHP handlers and paths. If your website has hard-coded PHP handlers and paths, it might be correct for the old server but not ours.

Using an incorrect PHP handler, session path, or other PHP directives can cause various errors that might produce vague error messages that do not directly indicate the primary issue. These errors include:

 

Error:

"Your PHP installation appears to be missing the MySQL extension which is required by WordPress

Please check that the mysqli PHP extension is installed and enabled."

Or,

"PHP Warning: session_start(): open(/var/cpanel/php/sessions/ea-php56/sess_03i13, O_RDWR) failed: No such file or directory"

Or,

403 Forbidden
Access to this resource on the server is denied!

Or,

PHP extension missing: You have enabled the PHP extension in "Select PHP Version/PHP.ini," but it has not been enabled, or it is missing in PHPInfo.

Note:

The exact error might be different on your website.

 

Applies To:

This guide applies to Web Hosting, Semi Dedicated Hosting, Reseller Hosting, and managed servers with CloudLinux installed.

 

Solution


Disable incorrect PHP paths (handler and session) in the .htaccess and/or .user.ini files.

  • Some websites have only one of these files in only one directory. Make sure to find the files in both home and public_html directories.

  • public_html is the default root directory for your primary domain. You can find the root directory of your additional domains in cPanel > Domains.

  • If you cannot find any of the files, enable "Show Hidden Files (dotfiles)" from File Manager > Settings.

  • You need to edit both files (if both exist) in both directories (if they exist in both directories) to disable incorrect PHP paths.

Delete the following lines:

  AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
  php_value session.save_path "/tmp"
  session.save_path = "/tmp"
  SetEnv PHPRC /home/customer/www/yourdomain.com/public_html/php.ini

 

Note:

  • Your file might have php56, php5, php81, php8, or phpXX, where XX represents a number.

  • Instead of "/tmp", you might have a different value, e.g., /var/cpanel/php/sessions/ea-php74.

 

Step By Step Instructions


  • Navigate to cPanel > Files > File Manager > public_html directory.

    On DirectAdmin: System Info & Files > File Manager.


  • Right-click on the .htaccess file and click "Edit".

    If you do not see the [.htaccess] file, enable "Show Hidden Files (dotfiles)" from File Manager > Settings.


  • Delete the following lines. They might be located in different places in your file.

       AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
       php_value session.save_path "/tmp"
       SetEnv PHPRC /home/customer/www/yourdomain.com/public_html/php.ini

    *Instead of "/tmp", you might have a different value, e.g., /var/cpanel/php/sessions/ea-php74.
    *Your file might have php56, php5, php81, php8, or phpXX where XX represents a number.


  • Repeat the above steps for the .user.ini file in the public_html directory.

    *Your website might not have a [.user.ini] file.

    In the .user.ini file, the session.save_path line will look like this:

    session.save_path = "/tmp"

    *Instead of "/tmp", you might have a different value, e.g., /var/cpanel/php/sessions/ea-php74.


  • Repeat the above steps for the .htaccess and .user.ini files in the home directory.

    *Your website might not have any [.htaccess] or [.user.ini] files in the [home] directory. In that case, no further action is necessary.


  • Done!

 

cPanel's MultiPHP uses the above PHP directives. We do not use MultiPHP; we use CloudLinux's PHP Selector only. Using these directives on our servers will cause errors. Using both PHP Selector and MultiPHP can also cause issues with PHP configuration and extensions.

 

  • 346 Users Found This Useful
Was this answer helpful?

Related Articles

How to reset or regenerate the .htaccess file in WordPress?

A [.htaccess] file is a configuration file that tells your server how to handle certain things on...

How to fix the 403 forbidden error in WordPress?

In this article, we will show you how to easily fix the 403 forbidden error in WordPress. What...

How to deactivate plugins when not able to access WordPress admin?

Often during troubleshooting, you may need to deactivate all plugins and activate them one by...

How to fix errors after migrating WordPress?

  Migrations from cPanel-based servers are usually seamless. But sometimes, a few issues might...

Fix missing MySQL extension or PHP extension or session error

  The most common reason for the error is using an invalid PHP handler/directive in the...