[Solved] Unable to access files outside of VH_ROOT

Discussion in 'Install/Configuration' started by LunarCraft, May 30, 2011.

  1. LunarCraft

    LunarCraft Member

    Hi, I am fairly new to LiteSpeed and after setting up my virtual host everything seems to be working fine except from one thing. I am unable to access any of my files outside of the specified VH_ROOT.

    I have ensured that the option "Restrain" is not enabled.

    What I want to do is to be able to include a file that another program uses, for instance

    Any heads up on what to look for would be much appreciated!

    Error that occurs is just "An unexpected error occurred. Please try again later.", which leaves me much confusion.

    Edit: also should mention that I made sure everyone has read permissions for the file, so that is not the issue afaik.
    Last edited: May 30, 2011
  2. webizen

    webizen Well-Known Member

    add the path to open_basedir
  3. LunarCraft

    LunarCraft Member

    I am not sure if you read my question right. Cause after reading what it does, it seems to do the complete opposite of what I want to do.
    "open_basedir, if set, limits all file operations to the defined directory and below.", what I want to do is the opposite.
    I want to be able to include a file outside of my www folder, adding open_basedir broke the entire website as none of the actual website files are in that folder. Apache allows this by default, is there no other way to get it to work the same way?
  4. webizen

    webizen Well-Known Member

    If open_basedir is not empty, then you can add additional path to that (hence the suggestion) so that files from other places can be included. You can verify your open_basedir setting via a phpinfo page. if open_basedir is already empty (not set), then no need to worry about this.

    please also check error.log or stderr.log for any indication. btw, what server environment and lsws version are you running?
  5. LunarCraft

    LunarCraft Member

    phpinfo reports
    I am running LiteSpeed 4.1.1 Standard in an CentOS 5.6 X86_64 environment.

    I went through the logs, but I cannot find anything besides the error that occurs when I try to open the file in php, and it seems to infinite loop itself too. I have about 50 files of 50MB each saying that it cannot open the file because a boolean was given instead, this is not an issue when I move the file to the VH_ROOT folder, it works like expected then.

    Sadly that won't work for me. :(
  6. webizen

    webizen Well-Known Member

    can you post a code snippet in question? also see if the following works for you.

    $file_handle = fopen("/etc/passwd", "r");
    while (!feof($file_handle)) {
    $line_of_text = fgets($file_handle);
    print $line_of_text . "<BR>";
  7. LunarCraft

    LunarCraft Member

    For some reason that works for me.
    $consoleOptions['pathOP'] equals /home/username/server/ops.txt (username is clearly not the real one). This worked fine prior to switching to litespeed.
    <?php if ( !defined('directblock') )
    'Are you trying to hack me?');

    $urls $consoleOptions['pathOP'];
    $page join("",file("$urls"));
    $kw explode("\n"$page);
    $allowedOPS = array();
    $allowedOPS['name'] = $kw;
    edit: I noticed this also happens to my XML feed.
    The following also returns an "An unexpected error occurred. Please try again later."

    $url 'http://anexternalserver/afolder/update/feed.xml';
    $xml simplexml_load_file($url);
    $lp_version $xml->checks[0]->buildnumber;
    if (
    $lp_version $lunarbuild) {
    nl2br('<b><span style="color: red;">There is a newer version available: '.'<i>'.$xml->checks->buildnumber.'</span></i></b>');
    // Some information about the new build...
    echo nl2br('<pre>Main change: '.$xml->checks->buildnotes."\nSize: ".$xml->checks->buildsize."\nLink: <a href=".$xml->checks->buildurl.'>'.$xml->checks->buildurl.'</a></pre>');
    }else{ echo 
    nl2br("<span style='color: green;'><b>Currently up to date.</b></span>\n"); }
    Edit2: I made my virtual host not use my server's log, nothing in it at all regarding the issues. error.log is empty and only the access.log gets filled up, stderr.log is also empty..

    Edit3: After more troubleshooting I seem to have fixed the include error. Now I face the other question as previously mentioned. My XML feed gets the same "unexpected error" message, code was working fine in Apache and the XML is hosted externally.
    Last edited: May 31, 2011
  8. webizen

    webizen Well-Known Member

    pls paste some content of feed.xml here or pm the actual URL.
  9. LunarCraft

    LunarCraft Member

    So far the XML looks like this.
    <?xml version="1.0" encoding="UTF-8"?>
  10. webizen

    webizen Well-Known Member

    check "allow_url_fopen" in phpinfo and make sure it is On.
  11. LunarCraft

    LunarCraft Member

    Thank you so much, can't believe I didn't see this before.
  12. webizen

    webizen Well-Known Member

    PHP in LSWS (LSPHP) may use different php.ini than the one for Apache. So if switch from Apache to LSWS, it is recommended you build matching PHP and make sure php.ini the same as Apache's (not necessarily the same file but same copy) in LSWS prior to switch to avoid issues like this.
    Last edited: Jun 2, 2011

Share This Page