Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

open_basedir restriction in effect error in php code

Im beginner in php language. in my web project i created a filepath.config.ini file which stores all file path in the website directories. for eg. CLASS1 = bin/myclass1.php CLASS2 = bin/myclass2.php

and im accessing those path by using:

require $_SERVER['DOCUMENT_ROOT'].'/'.GetfilePath('CLASS1');

in localhost server its working good and giving me path like this

D:/myproject/bin/myclass1.php

when i upload those file on test server im getting this open_basedir restriction error.

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/usr/local/apache/htdocs/projectfolder/bin/myclass1.php) is not within the allowed path(s): (/home/:/usr/lib/php:/tmp) 

i know we can disable this restriction...but i dont know how to do that :P. but is it good to use this server DOCUMENT_ROOT ??? or is their any alternate way to use the file path? what you people do to access those file path. and what happen if i disable the open_basedir restriction? is it secure to do that? please help me what to do?

like image 406
Ashish Panwar Avatar asked Feb 06 '26 13:02

Ashish Panwar


1 Answers

Edit your php.ini file (PHP: Configuration Changes) and either disable open_basedir or add /usr/local/apache/htdocs to it.

like image 172
Eric Coleman Avatar answered Feb 08 '26 04:02

Eric Coleman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!