The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

open_basedir path

Discussion in 'General Discussion' started by ken yau, May 14, 2014.

  1. ken yau

    ken yau Member

    Joined:
    May 4, 2014
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    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.
     
  2. cPanelPeter

    cPanelPeter Technical Analyst III
    Staff Member

    Joined:
    Sep 23, 2013
    Messages:
    569
    Likes Received:
    15
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Twitter:
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
  4. ken yau

    ken yau Member

    Joined:
    May 4, 2014
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    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.
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
  6. ken yau

    ken yau Member

    Joined:
    May 4, 2014
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Thank you very much.I understand now.
     
  7. ken yau

    ken yau Member

    Joined:
    May 4, 2014
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    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
     
  8. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
  9. Clouseau

    Clouseau Active Member

    Joined:
    Jan 17, 2015
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    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?
     
    #9 Clouseau, Jan 22, 2015
    Last edited: Jan 22, 2015
  10. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
Loading...

Share This Page