[Solved] Unable to access files outside of VH_ROOT

#1
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
/home/username/logs/ops.txt

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:
#3
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?
 

webizen

Well-Known Member
#4
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
phpinfo reports
open_basedir no value no value
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. :(
 

webizen

Well-Known Member
#6
can you post a code snippet in question? also see if the following works for you.

Code:
<HTML>
<BODY>
<?php
$file_handle = fopen("/etc/passwd", "r");

while (!feof($file_handle)) {

$line_of_text = fgets($file_handle);
print $line_of_text . "<BR>";

}

fclose($file_handle);
?>
</BODY>
</HTML>
 
#7
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:
<?php if ( !defined('directblock') )
{
	die('Are you trying to hack me?');
} 
$urls = $consoleOptions['pathOP'];
$page = join("",file("$urls"));
$kw = explode("\n", $page);
$allowedOPS = array();
for($i=0;$i<count($kw);$i++){
$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."

PHP:
$url = 'http://anexternalserver/afolder/update/feed.xml';
$xml = simplexml_load_file($url);
$lp_version = $xml->checks[0]->buildnumber;
if ($lp_version > $lunarbuild) {
    echo 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:
#9
So far the XML looks like this.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<update>
	<checks>
		<buildnumber>0.2c</buildnumber>
        <buildurl>http://lunarcraft.org/?p=buildlink</buildurl>
        <buildnotes>Spacer</buildnotes>
        <buildsize>Spacer</buildsize>
	</checks>
</update>
 

webizen

Well-Known Member
#12
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:
Top