How to configure SuPHP to use only the MultiPHP INI file, not user inis, and open_basedir?

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,203
363
Hello @bgarrant,

Yes, those values look to match what's referenced earlier in this thread.

Next, do I need to place an open_basedir value in the global php.ini file as you can see no value is set? If so, what should it be?
Each user requires their own custom open_basedir vaues in their PHP configuration files when you select a PHP handler that is not DSO. Setting a global open_basedir value for suPHP isn't supported at this time.

and it makes it so it can't be modified. Is that best way to handle that? What do you recommend as we do not want users to be able to change any overrides we have in the .user.ini file?
Using chattr to prevent modifications to a file is not something we recommend. Additionally, we recommend using the INI Editor in cPanel to make these types of changes as this ensures the proper entries/files are automatically populated in the event the handler changes in the future. There's not currently a supported method to prevent user modifications to individual PHP configuration files with suPHP, aside from the workarounds referenced in this post:

How to configure SuPHP to use only the MultiPHP INI file, not user inis, and open_basedir?

Thank you.
 

bgarrant

Well-Known Member
Jun 27, 2012
78
10
8
cPanel Access Level
Root Administrator
Hello @bgarrant,

Yes, those values look to match what's referenced earlier in this thread.

Hello @bgarrant,

Yes, those values look to match what's referenced earlier in this thread.



Each user requires their own custom open_basedir vaues in their PHP configuration files when you select a PHP handler that is not DSO. Setting a global open_basedir value for suPHP isn't supported at this time.



Using chattr to prevent modifications to a file is not something we recommend. Additionally, we recommend using the INI Editor in cPanel to make these types of changes as this ensures the proper entries/files are automatically populated in the event the handler changes in the future. There's not currently a supported method to prevent user modifications to individual PHP configuration files with suPHP, aside from the workarounds referenced in this post:

How to configure SuPHP to use only the MultiPHP INI file, not user inis, and open_basedir?

Thank you.

Each user requires their own custom open_basedir vaues in their PHP configuration files when you select a PHP handler that is not DSO. Setting a global open_basedir value for suPHP isn't supported at this time.



Using chattr to prevent modifications to a file is not something we recommend. Additionally, we recommend using the INI Editor in cPanel to make these types of changes as this ensures the proper entries/files are automatically populated in the event the handler changes in the future. There's not currently a supported method to prevent user modifications to individual PHP configuration files with suPHP, aside from the workarounds referenced in this post:

How to configure SuPHP to use only the MultiPHP INI file, not user inis, and open_basedir?

Thank you.
@cPanelMichael

Couple questions then I am all set I think.

So if I want to add an open_basedir entry for each domain, should I add it to the home directory or the domain location (public_html). I prefer to have it above webroot if we can, but that did not seem to work using the Multi editor. Please advise.

Since no users have a php.ini file yet, do I need to add a basic one first, then the entry in the Editor view for open_basedir? Would user.ini be preferred?

Also, I noticed the PHP.ini created does not match the .user.ini when you add with Editir view. Do I need to copy over open_basedir line?

Lastly, how do I make the open_basedir to work global for the domain? It does not seem to work in subfolders or anywhere else other than its own folder? Do I need to comment out open_basedir in the Global server php71 PHP.ini i assume?

Thanks in advance
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,203
363
So if I want to add an open_basedir entry for each domain, should I add it to the home directory or the domain location (public_html). I prefer to have it above webroot if we can, but that did not seem to work using the Multi editor. Please advise.
The default entry, and the one I used when testing earlier in the thread, was "/home/username/".

Since no users have a php.ini file yet, do I need to add a basic one first, then the entry in the Editor view for open_basedir? Would user.ini be preferred?
No, the MultiPHP INI Editor feature will take care of all of that for you. There's no need to manually modify or create any files.

Also, I noticed the PHP.ini created does not match the .user.ini when you add with Editir view. Do I need to copy over open_basedir line?
No manual modifications are required. The INI Editor in cPanel should automatically populate the required files with the correct entries.

Lastly, how do I make the open_basedir to work global for the domain? It does not seem to work in subfolders or anywhere else other than its own folder? Do I need to comment out open_basedir in the Global server php71 PHP.ini i assume?
Adding a global value isn't supported with suPHP, so you should remove the global entry to verify if that's the reason it's not working.

Thank you.
 

bgarrant

Well-Known Member
Jun 27, 2012
78
10
8
cPanel Access Level
Root Administrator
The default entry, and the one I used when testing earlier in the thread, was "/home/username/".



No, the MultiPHP INI Editor feature will take care of all of that for you. There's no need to manually modify or create any files.



No manual modifications are required. The INI Editor in cPanel should automatically populate the required files with the correct entries.



Adding a global value isn't supported with suPHP, so you should remove the global entry to verify if that's the reason it's not working.

Thank you.
@cPanelMichael

I created it exactly as you said, but the files in public_html are not seeing the new php.ini, .user.ini or .htaccess files in the "/home/user" directory. What is missing?

here is what it created:

/home/perufcu/php.ini

Code:
; 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)

open_basedir = "/home/perufcu:/usr/lib/php:/usr/local/lib/php:/tmp:/opt/cpanel/ea-php71/root/usr/bin/php:/usr/local/bin/ea-php71:/usr/bin/ea-php71:/var/cpanel/php/sessions/ea-php71"
allow_url_fopen = Off
allow_url_include = Off
display_errors = Off
enable_dl = Off
file_uploads = On
max_execution_time = 90
max_input_time = 120
max_input_vars = 1000
memory_limit = 512M
post_max_size = 16M
session.gc_maxlifetime = 1440
session.save_path = "/var/cpanel/php/sessions/ea-php71"
upload_max_filesize = 16M
zlib.output_compression = Off
/home/perufcu/.user.ini

Code:
; 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)
[PHP]
display_errors = Off
max_execution_time = 90
max_input_time = 120
max_input_vars = 1000
memory_limit = 512M
post_max_size = 16M
session.gc_maxlifetime = 1440
session.save_path = "/var/cpanel/php/sessions/ea-php71"
upload_max_filesize = 16M
zlib.output_compression = Off
/home/perufcu/.htaccess

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 php7_module>
   php_flag display_errors Off
   php_value max_execution_time 90
   php_value max_input_time 120
   php_value max_input_vars 1000
   php_value memory_limit 512M
   php_value post_max_size 16M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php71"
   php_value upload_max_filesize 16M
   php_flag zlib.output_compression Off
</IfModule>
# END cPanel-generated php ini directives, do not edit
phpinfo() to look and you see it is not loading correct ini file and open_basedir is missing.
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,203
363
phpinfo() to look and you see it is not loading correct ini file and open_basedir is missing.
To clarify, are you using suPHP as the handler for the version of PHP assigned to the account, and is PHP-FPM disabled for this account when checking from "WHM >> MultiPHP Manager"?

Thank you.
 

bgarrant

Well-Known Member
Jun 27, 2012
78
10
8
cPanel Access Level
Root Administrator
To clarify, are you using suPHP as the handler for the version of PHP assigned to the account, and is PHP-FPM disabled for this account when checking from "WHM >> MultiPHP Manager"?

Thank you.
@cPanelMichael

It is like the folders in public_html and below are not seeing the INI files above the webroot. There is no php.ini or .user.ini in the public_html folder. There is a .htaccess file in the /public_html folder which came from the Statamic CMS, but it does not look like that would affect anything at all.

I tested even without the public_html/.htaccess it and the PHP info page still won't see the newly added ini files

phpinfo()
 
Last edited:

bgarrant

Well-Known Member
Jun 27, 2012
78
10
8
cPanel Access Level
Root Administrator
To clarify, are you using suPHP as the handler for the version of PHP assigned to the account, and is PHP-FPM disabled for this account when checking from "WHM >> MultiPHP Manager"?

Thank you.
something is definitely wrong. The only thing that works in manually creating a .user.ini file, placing it in "home/user" directory. The content of the file are:

Code:
open_basedir = "/home/perufcu:/usr/lib/php:/usr/local/lib/php:/tmp:/opt/cpanel/ea-php71/root/usr/bin/php:/usr/local/bin/ea-php71:/usr/bin/ea-php71:/var/cpanel/php/sessions/ea-php71"
Can a .user.ini be placed in the Home Directory like this (/home/perufcu/.user.ini)? I normally see them in public_html folders but is it OK? It seems to add the open_basedir and is recursive.





q
 

bgarrant

Well-Known Member
Jun 27, 2012
78
10
8
cPanel Access Level
Root Administrator
To clarify, are you using suPHP as the handler for the version of PHP assigned to the account, and is PHP-FPM disabled for this account when checking from "WHM >> MultiPHP Manager"?

Thank you.
@cPanelMichael

So from the docs it says that if suPHP is the handler I should have a custom PHP.ini created. Why is mine also creating a .user.ini and .htaccess files?

For some reason when I create an ini using the tool in cPanel in the Home Directory my site will not use the new ini file. No idea why. It is supposed to.

Should we open a ticket or upgrade to cPanel 70?