Sometimes it becomes useful to add an additional filetype that is executed as PHP code. cPanel offers an interface for registering custom MIME types, allowing other file types to be executed by the PHP processor.
Procedure
Determine a user’s PHP version
You can determine a user’s PHP version with one of the following methods:
- Use WHM’s MultiPHP Manager interface (WHM >> Home >> Software >> MultiPHP Manager). This interface allows you to see and change a user’s default PHP version. This is the easiest method to determine a user’s PHP version.
- Use cPanel’s MultiPHP Manager interface (cPanel >> Home >> Software >> MultiPHP Manager).
- Navigate to the /home/username/public_html directory, where "username" represents the user’s username. Run the following command on the command line:
cat .htaccess
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
- In the above example, # Set the “ea-php73” package as the default indicates that the site uses the cPanel provided EasyApache PHP 7.3.
- Use WHM API 1’s php_get_vhost_versions function.
- Use UAPI’s LangPHP::php_get_vhost_versions function.
Add the new handler
Navigate to cPanel > MIME Types. On this page, there are two fields we're concerned with.
In the MIME Type field, add an application handler using the following format, where XX is the provider (ea or alt) and YY is the version number without the decimal
application/x-httpd-XX-phpYY
In the second field, add the file extensions you'd like to load via the PHP processor.
Please be warned, this will not be affected by changes made in the MultiPHP Manager.