Cormac Kernan

Registered
May 17, 2017
2
0
1
Belfast
cPanel Access Level
Root Administrator
I am using CentOS 6.9, cPanel 64.0 (build 21), PHP 7 with PHP-FPM with some sites and I am having difficulty getting .user.ini files to work recursively. The problem is described and solved here (although not for cPanel):

stackoverflow.com/questions/27226055/does-the-user-ini-file-work-for-subdirectories

Essentially the problem is that cPanel adds a slash to the end of the PHP-FPM proxy address as below:

Code:
SetHandler proxy:unix:/opt/cpanel/ea-php70/root/usr/var/run/php-fpm/5109b0c98599403f47e6e1f35c4510ebc9d8bcfb.sock|fcgi://domain.tld/
Looking at the phpinfo for a site with this setting shows that the $_SERVER['SCRIPT_FILENAME'] variable ends up being prepended with a // similar to:

Code:
$_SERVER['SCRIPT_FILENAME']    //home/account/app/public_html/info.php
This then has the effect of .user.ini files not being read by sub-directories and can only be rectified by placing another .user.ini in the sub-directory itself, which is obviously not ideal as I want the settings in my webroot .user.ini to be effective across all sub-directories, similar to how php_value settings work in a .htaccess file.

By taking the slash away from the end of the SetHandler line within the httpd.conf file directly and restarting Apache the problem is temporarily solved. However, because of how cPanel works the next rebuild of the httpd.conf file will add the trailing slash again. Although cPanel allows specific virtualhost settings by adding files to the /etc/apache2/conf.d/userdata directory, the include of these settings happens in the httpd.conf file before the SetHandler line is added, meaning we cannot customise this line.

Is there another way to fix this at a global level within my cPanel install?
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,260
463
Hello,

Internal case EA-6167 is open to address an issue where PHP-FPM in combination with .user.ini files acts non-recursively in the public_html directory due to trailing slash in proxy_fcgi_module configuration. I'll update this thread with more information on the status of this case as it becomes available. In the meantime, you can create custom Apache Virtual Host templates as a temporary workaround. EX:

Code:
cp -a /var/cpanel/templates/apache2_4/vhost.default /var/cpanel/templates/apache2_4/vhost.local
cp -a /var/cpanel/templates/apache2_4/ssl_vhost.default /var/cpanel/templates/apache2_4/ssl_vhost.local
Once you create the local template files, you can modify the .local files to modify the PHP-FPM entry from:

Code:
[%- IF vhost.php_fpm %]
    <IfModule proxy_fcgi_module>
        <FilesMatch \.(phtml|php[0-9]*)$>
            SetHandler proxy:unix:[% vhost.php_fpm_socket %]|fcgi://[% wildcard_safe(vhost.servername) %]/
        </FilesMatch>
    </IfModule>
To:

Code:
[%- IF vhost.php_fpm %]
    <IfModule proxy_fcgi_module>
        <FilesMatch \.(phtml|php[0-9]*)$>
            SetHandler proxy:unix:[% vhost.php_fpm_socket %]|fcgi://[% wildcard_safe(vhost.servername) %]
        </FilesMatch>
    </IfModule>
Then, rebuild the Apache configuration file:

Code:
/scripts/rebuildhttpdconf
Thank you.
 

Cormac Kernan

Registered
May 17, 2017
2
0
1
Belfast
cPanel Access Level
Root Administrator
Great temporary solution - that's worked a treat. Hopefully, a later cPanel release will fix this issue and then presumably we should revert to the vhost.default and ssl_vhost.default files in case we miss any future updates to these files?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,260
463
Great temporary solution - that's worked a treat. Hopefully, a later cPanel release will fix this issue and then presumably we should revert to the vhost.default and ssl_vhost.default files in case we miss any future updates to these files?
You could simply remove the .local files that you created to remove the customization once a resolution is published.

Thanks!
 

opt2bout

Well-Known Member
Nov 10, 2006
69
1
158
Any progress on fixing this? (Internal case EA-6167)
The default configuration in release 66 (Current) applies these changes automatically--so no need for .local versions when 66 goes to Release. I'm running Current and have removed my .local versions of my apache config.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,260
463
Any progress on fixing this? (Internal case EA-6167)
This was fixed as part of internal case HB-2719 in the most recent EasyApache 4 update:

1.0-107 - HB-2719: remove trailing slash from fcgi alias config line in template

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,260
463
What WHM version will this be included in?
EasyApache 4 updates are independent of cPanel updates. You should be able to use the "yum update" command to update the EA4 RPMs on your system.

Thank you.