|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29170 problem with open_basedir and include
Submitted: 2004-07-15 00:39 UTC Modified: 2005-01-31 23:07 UTC
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: phynias at camphreaks dot com Assigned:
Status: Not a bug Package: Safe Mode/open_basedir
PHP Version: 5.0.0 OS: Redhat 9
Private report: No CVE-ID: None
 [2004-07-15 00:39 UTC] phynias at camphreaks dot com
When open_basedir options or set on a a set within apache.
Such as:
php_admin_value open_basedir"/home/httpd/vhosts/"

If I do an include form 1 page and then in that page inlcude another page it errors out with 
open_basedir restriction in effect.

Easiest way to test it is to do the following.
in your docroot create a file called test.php inside test.php put <? include('inc/include1.php');?>
then inside include1.php put
<? include('inc2/include2.php'); ?>
and inside include2.php put
<? print "hello world"; ?>

So if yer vase was /httpd/docroot you would have


Then bring up test.php in your browser.

Of course u must have the dirs /inc and inc/inc2 created
This will include the first file but error on the second one.

Actual result:
Warning: main() [function.main]: open_basedir restriction in effect. File(/usr/share/pear/include/inc2.php) is not within the allowed path(s): (/home/httpd/vhosts/ in /home/httpd/vhosts/ on line 2

Warning: main(include/inc2.php) [function.main]: failed to open stream: Operation not permitted in /home/httpd/vhosts/ on line 2

Warning: main() [function.include]: Failed opening 'include/inc2.php' for inclusion (include_path='.:./:/usr/share/pear:/php/includes:') in /home/httpd/vhosts/ on line 2


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-03 16:42 UTC] kuba at 3net dot pl
the same story....
when this issue will be solved?
do i have to change my software, install old php 4.3.7,
or wait for you to solve it?
 [2004-08-03 16:49 UTC]
use absolute path with include() and all other functions.
include (ROOT_PATH.'/inc/include1.php');
it will work perfectly at all hostings, all platforms, all versions etc. etc.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Jun 17 18:01:28 2021 UTC