Forum Moderators: coopster

Message Too Old, No Replies

INCLUDE PATH not WORKING outside doc root

INCLUDE_PATH not WORKING outside doc root

         

Dcipher

2:29 am on Dec 26, 2008 (gmt 0)

10+ Year Member



Hi,

Environment: Virtual dedicated, Linux, Apache 2.2.8, PHP 5.2.6

I have an application that I placed above my doc root (httpdocs). The only files in my doc root are my index.php, and my images, css, js etc. All application files are 1 folder above the doc root.

When I visit the doc root, all I get is a blank page.

I have tried ini_set, & include_path in the php.ini. Neither of them allows for me to include() any files from my application.

Does anyone know how I can successfully include my files? Any ideas or assistance would really help.

Thanks

penders

1:00 pm on Dec 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi Dcipher, and welcome to WebmasterWorld....

What are you trying to set your include_path to, and what are you passing to your include statement?

If you were to visit index.php in your docroot and you try to include a file using a relative path (eg. above your docroot and into a sub folder called 'myapp')...

include('../myapp/test.php');

Does this work?

g1smd

6:36 pm on Dec 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I usually set the include file path in the .htaccess file using

php_value include_path /vhost/vhost4/e/x/example.com/www/includes

Dcipher

7:15 pm on Dec 26, 2008 (gmt 0)

10+ Year Member



Thanks for the replies

penders
"include('../myapp/test.php');" does not work, it just leaves a blank page.

g1smd
"php_value include_path /vhost/vhost4/e/x/example.com/www/includes " that does the same thing.

I thought that once you include a file you should be able to include it from anywhere on the server once its set in the include path. What could be the issue?

penders

1:06 pm on Dec 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I thought that once you include a file you should be able to include it from anywhere on the server once its set in the include path.

Yes, this is the idea.

Usually (ie. on a shared host) you need to set the include_path on each page request, since you don't normally have access to php.ini in order to set it permanently. Or set it in .htaccess like g1smd suggests. Or set it in a common config.php file in a known location (ie. your docroot) that you include on every page before you try to include anything else.

Assuming you have your paths correct, it's strange that you get a blank page. Have you checked your server error log? Make sure there are no parse errors?! I have also been developing on a virtual dedicated server recently and a very annoying quirk with the setup (something I've been unable to change) is that I get a "500 Internal Server Error" if a parse error occurs in the main (index.php) file [webmasterworld.com] which results in a blank page being output (but the actual error appears in the error.log) - worth a check.

Dcipher

1:26 am on Dec 28, 2008 (gmt 0)

10+ Year Member



After much investigating I found the answer is based on the apache 'php_admin_value open_basedir' set in the httpd.conf. Once I edited this, everything works just fine now.