How to Change PHP Version for a Specific Directory?

Under PHP Manager in cPanel you can change the PHP version for the entire hosting account or for a specific directory.

Below you can read how to set a different PHP version for a specific directory (website) of your hosting account.

Choosing a PHP Version (FastCGI) for a Specific Directory

You can enable a different PHP version for a certain directory (website) in two easy steps.

You first need to access “Set the PHP version for a particular directory” section under PHP Manager in cPanel.

Choosing PHP version and directory

From the options there you have to select the PHP version (1) and enter the desired directory (2). Finish the setup by clicking the Add button (3).

You need to create an .htaccess file or edit the existing one, located in the same directory. Afterwards, you should add the following lines to the file:

<IfModule mod_fcgid.c>
AddHandler fcgid-script .php
FcgidWrapper /home/cpuser/dir/php.fcgi .php
/home/cpuser/dir/ – replace it with the path to the directory;

You can copy these lines directly from the PHP manager after adding the system files to the desired directory.

After saving the changes in the .htaccess file, the selected PHP version will be enabled for the specified directory. You can check the PHP version that is enabled for the directory by placing a PHP file with phpinfo().

After activating the PHP version, the two files – php.fcgi and phpXX-fcgi.ini – will be automatically added to the directory. You can use phpXX-fcgi.ini to edit PHP directives. In addition, a separate phpXX.ini configuration file is created, which is used only to manage PHP modules. This file can be found in the hosting account, in the directory:


phpXXreplace with the version of PHP;

Important: If there is an already existing .htaccess file that contains a line for PHP version setup such as AddHandler x-httpd-phpXX .php, you will have to remove it.
If you have difficulty with PHP settings in your hosting account, do not hesitate to сontact SuperHosting.BG technical support team.
Updated on 09.02.2023

Was this article helpful?

Related Articles