cPanel-generated php ini directives

AndyX

Well-Known Member
Sep 25, 2015
142
21
68
Los Altos, CA
cPanel Access Level
Root Administrator
In my .htaccess file I have the following:

Code:
# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php8_module>
   php_flag display_errors On
   php_value max_execution_time 30
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 32M
   php_value post_max_size 50M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php80"
   php_value upload_max_filesize 50M
   php_flag zlib.output_compression Off
</IfModule>
<IfModule lsapi_module>
   php_flag display_errors On
   php_value max_execution_time 30
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 32M
   php_value post_max_size 50M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php80"
   php_value upload_max_filesize 50M
   php_flag zlib.output_compression Off
</IfModule>
# END cPanel-generated php ini directives, do not edit

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php80” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php80 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
Why is cPanel adding this? I noticed that on some server it's not being added. Is there a way to not add the code?
 

Babene7

Active Member
Apr 13, 2017
41
9
58
Earth
cPanel Access Level
Root Administrator
Hey,

That is added by cPanel's MultiPHP INI Editor and by cPanel's MultiPHP Manager:


If you use these tools to modify a domain/subdomain's PHP settings and/or version, then those lines are added to your .htaccess file, and a php.ini file is created too. It's standard behavior, don't worry.

If some sites don't have it, it's simply because you haven't used those tools on them (or because the lines were removed).

In case you want that code deleted, you can do it by using the mentioned tools, though keep in mind that you may break the site if you do this.
 
  • Like
Reactions: cPRex

AndyX

Well-Known Member
Sep 25, 2015
142
21
68
Los Altos, CA
cPanel Access Level
Root Administrator
Thank you for the above links and information.

I'm still unclear why it's added. What useful purpose does it serve? If the code can be deleted without any effect it would appear to have no useful purpose.
 

cPanelWilliam

Administrator
Staff member
Mar 13, 2018
101
16
93
Houston
cPanel Access Level
Root Administrator
Hello! As @Babene7 said, most of those directives are added from within the MultiPHP INI Editor and can be removed/edited from within that interface as well. A few of the directives are necessary for setting the PHP handler and version so those cannot be removed, but you can change the PHP values such as max_input_time.
 
  • Like
Reactions: Babene7

AndyX

Well-Known Member
Sep 25, 2015
142
21
68
Los Altos, CA
cPanel Access Level
Root Administrator
Hello! As @Babene7 said, most of those directives are added from within the MultiPHP INI Editor and can be removed/edited from within that interface as well. A few of the directives are necessary for setting the PHP handler and version so those cannot be removed, but you can change the PHP values such as max_input_time.
Hello,

I'm not finding this to be the case. I have removed the entire code without any issue. Can you double check if the code is actually needed.

Thank you.
 

cPanelWilliam

Administrator
Staff member
Mar 13, 2018
101
16
93
Houston
cPanel Access Level
Root Administrator
Hello, although removing the code may not directly result in an error on the website, I wouldn't recommend doing this as it could cause unforeseen issues. The code is used by cPanel to manage the PHP configuration for the domain.

Whenever a user makes a change via the MultiPHP INI Editor or MultiPHP INI Manager some of the code would get added back automatically.

Did you have a specific reason you were needing to remove the code?
 

AndyX

Well-Known Member
Sep 25, 2015
142
21
68
Los Altos, CA
cPanel Access Level
Root Administrator
Perhaps the reason for the code is to allow different domains to run different versions of PHP. So if you only have one domain the default PHP directives in cPanel apply and removing the code in the .htaccess file will not be an issue.
 

cPanelWilliam

Administrator
Staff member
Mar 13, 2018
101
16
93
Houston
cPanel Access Level
Root Administrator
Hello,

Perhaps the reason for the code is to allow different domains to run different versions of PHP. So if you only have one domain the default PHP directives in cPanel apply and removing the code in the .htaccess file will not be an issue.
Correct, the directives added by cPanel are mostly used to manage different PHP versions between your domains. If none of the code was inserted, the domain would use the server's default PHP version.

For example, if you set the domain to Inherit in the MultiPHP Manager in WHM, only the following should be added to the .htaccess which should not affect the website:

Code:
# php -- BEGIN cPanel-generated handler, do not edit
# This domain inherits the “PHP” package.
# php -- END cPanel-generated handler, do not edit
 

AndyX

Well-Known Member
Sep 25, 2015
142
21
68
Los Altos, CA
cPanel Access Level
Root Administrator
only the following should be added to the .htaccess which should not affect the website:
I cannot get the above 3 line comment to show. I do the following

I first delete the code in my .htaccess file which is shown in post #1.

I have set the WHM -> Inherit - PHP 8.0 ( ea-php80 )

I then make a change in cPanel -> MultiPHP INI Editor and Apply.

The code as shown in post #1 is added to the .htaccess file. I was hoping to only get the 3 line as indicated by cPanelWilliam.
 

cPanelWilliam

Administrator
Staff member
Mar 13, 2018
101
16
93
Houston
cPanel Access Level
Root Administrator
Hi,

Making changes within the cPanel MultiPHP INI Editor will add some directives back to the .htaccess. For example, you may see the default PHP directives added to the .htaccess such as the following after saving changes with the cPanel MultiPHP INI Editor:

Code:
<IfModule lsapi_module>
   php_flag display_errors Off
   php_value max_execution_time 60
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 32M
   php_value post_max_size 8M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php80"
   php_value upload_max_filesize 2M
   php_flag zlib.output_compression Off
</IfModule>
This additional code shouldn't cause any issues as the only directives that are changed are the ones changed by the user within the MultiPHP INI Editor. You could restore the .htaccess from an older copy to revert this code, but the additional code would get added back whenever a change is saved via the MultiPHP INI Editor in cPanel.
 

cPanelWilliam

Administrator
Staff member
Mar 13, 2018
101
16
93
Houston
cPanel Access Level
Root Administrator
Hi,

Is this something new? I don't recall having this code added to the .htaccess file over the years.
I believe the additional code added in the .htaccess from the MultiPHP INI Editor has been around since the introduction of EasyApache 4 since this allowed the use of multiple PHP versions across different domains. If you had an older server that used EasyApache 3 it could explain the difference in behavior you're seeing.