Hello,

Currently I'm getting the "open_basedir Restriction in Effect" error when trying to require a file in this manner:

require_once('/includes/folder/file.php');

To avoid the error I have to use a document relative path like this:

require_once('../../includes/folder/file.php');

I would like to use the first path because I can reuse such code in different pages in different directories without worrying about the path breaking.

How can I disable open_basedir so that the first path will be allowed?

Also for safety's sake, if possible I would only like to disable it for the public_html directory and it's child directories etc.

So any file in: /home/user/public_html (and it's child directories)
Can require any other file in: /home/user/public_html (and it's child directories)

I have root access if needed.

Thank you for any help!

    Actually I found there was an option in cPanel's WHM under "Tweak Security" that allows me to disable open_basedir on a per domain basis. Since all the domains/sites are under my control, I guess I don't have to really worry about only disabling it for the public_html directory of that domain.

    But disabling open_basedir has created another problem(of course) which I will post in the coding forum.

    Thanks to any and all for reading this.

      Set open_basedir to /home/user/

      And you cannot use require_once('/includes/folder/file.php'). Remember that with that you are trying to get files from serverdirectory /includes/folder/ and Im sure that your servers root directory you dont have directory called includes 🙂

      Use absolute path ie.:

      require_once('/home/user/includes/folder/file.php');
      

      ..or if its in public_html folder:

      require_once($_SERVER['DOCUMET_ROOT'].'/includes/folder/file.php');
      // The same as
      require_once('/home/user/public_html/includes/folder/file.php');
      

        Thanks cahva,

        Where would I set this?: Set open_basedir to /home/user/

        Yeah the stuff about the path is what I was talking about when I mentioned the other problem. Damn, PHP should really come up with a feature that interprets require paths the same way image or link paths are interpreted by the server.

        Peter

          in httpd.conf(under your vhost or directory):

          php_admin_value open_basedir /home/user

            Write a Reply...