ken yau

Member
May 4, 2014
9
0
1
cPanel Access Level
Root Administrator
Hello everybode,

Can any body tell me how to set the open_basedir path in php.ini if I use suphp?
What paths should be included in the open_basedir path?
Thank you very much.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,215
363
Hello :)

Per the user interface, if PHP is configured to run as a CGI, SuPHP or FastCGI process, the open_basedir setting must be manually specified in the relevant php.ini file. There is a post on this here that you might find helpful:

open_basedir with suPHP

Thnak you.
 

ken yau

Member
May 4, 2014
9
0
1
cPanel Access Level
Root Administrator
Hello,
I read the post before but I want to make sure that just the three paths:
open_basedir = /home/:/usr/lib/php:/usr/local/lib/php:/tmp
will make all the websites work probably since I host 3 websites in my VPS.
I also found some posts stated that
open_basedir = /home/users/you/public_html vs open_basedir = /home/
Will it be fine to use that path so it is more specific?
Thank you very much.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,215
363
You can edit the path so that it's restricted to the account's home directory. Remember this is for the individual php.ini within the account, and not the global php.ini file.

Thank you.
 

ken yau

Member
May 4, 2014
9
0
1
cPanel Access Level
Root Administrator
Hello cPanel staff,
One more question:
For the individual php.ini file ,should I copy the whole content of the global php.ini file then paste and modify what I need or just copy the part I need to modify (For example: just one line open_base_dir = /home/users/ ) ?
Thank you very much
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,215
363
I recommend copying the global php.ini file and then modifying it accordingly, as opposed to just creating an empty php.ini and adding individual entries.

Thank you.
 

Clouseau

Active Member
Jan 17, 2015
34
1
58
cPanel Access Level
Root Administrator
I have copied php.ini file from /usr/local/lib/php.ini to /home/martin/php.ini and I have added in it:
open_basedir = /home/:/usr/lib/php:/usr/local/lib/php:/tmp

Why can I still still access and read / through php script which is located in /home/martin/pubic_html/script.php?

And question number two, why not set this globally in whm in Service Configuration »
PHP Configuration Editor -> open_basedir?
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,215
363
I have copied php.ini file from /usr/local/lib/php.ini to /home/martin/php.ini and I have added in it:
open_basedir = /home/:/usr/lib/php:/usr/local/lib/php:/tmp

Why can I still still access and read / through php script which is located in /home/martin/pubic_html/script.php?
Hello :)

I'm not sure I understand the question here. Per our documentation:

It limits PHP's access to the user's home directory, /tmp, and a few necessary PHP system directories.

Based on your question, the PHP script is located in the user's home directory. Is that not the case?

Thank you.