PHP: Can’t Include File Outsite Web Root

After I transfered files from the original server to a testing server (which took 19 hours) I will have to run in with PostgreSQL. I asked for the database backup, upload it and restore to the testing server with this command:

psql -U username -d our_db < backup_file.sql

Everything was ready: I’ve set up the modules and other scripts outside the document root (based on the original setup) and placed all files to the document root.

Fire up the browser and point to the URL. Boom! It showed me a blank page. It took me several iterations to trace the real problem:

  • phpinfo()
  • Check PDO Postgres – found that it is alright
  • Check permissions – its all okay
  • Try the comment out technique

The last one lead me to the problem which was including files outside the document root. I also tried absolute URL but still didn’t work. After searching the Internet, I’ve found that the problem was because of the open_basedir restriction which won’t allow me to include files outside the document root.

This happened because we are in virtual hosts. All our projects are hosted in one testing server but with different virtual hosts which is setup via host file (in our case Windows XP host file).

Based on phpinfo() I found out that the open_basedir directive looks like this:


index.php is at: /home/httpd/vhosts/ourproject/httpdocs/index.php

But I need to include files at directories with same level as httpdocs like:


So therefore I need to modify the directive into:


I almost spend two hours on looking to these: searched all php.ini, httpd.con and related settings but at last I found the configuration file at:


After modifying the file, I restarted Apache via PLESK. Everything works file now!

1 thought on “PHP: Can’t Include File Outsite Web Root”

Leave a reply

Your email address will not be published. Required fields are marked *