Page 1 of 1

open_basedir restriction in effect need to open file from /home/

Posted: Thu Dec 15, 2016 5:25 pm
by hammy
Hello

I am trying to open a file in my website from my /home/geofile/ directory but I keep getting 'open_basedir restriction in effect'

Example of error code:-

Code: Select all

Warning: include(): open_basedir restriction in effect. File(/home/geofile/test.php) is not within the allowed path(s): (/home/mywebsiteuserfolder/web/vpstest.domain.info/public_html:/home/mywebsiteuserfolder/tmp) in /home/mywebsiteuserfolder/web/vpstest.domain.info/public_html/blah.php on line 28

Also

Code: Select all

Warning: fopen(): open_basedir restriction in effect. File(/home/geofile/GeoIP.dat) is not within the allowed path(s): (/home/mywebsiteuserfolder/web/vpstest.domain.info/public_html:/home/mywebsiteuserfolder/tmp) in /home/mywebsiteuserfolder/web/vpstest.domain.info/public_html/webfile/includes/geoip.inc on line 123

This is what is showing in my /usr/local/vesta/data/templates/web/httpd/basedir.stpl

Code: Select all

 <Directory %sdocroot%>
        AllowOverride All
        SSLRequireSSL
        Options +Includes -Indexes +ExecCGI
        php_admin_value open_basedir %docroot%:%home%/%user%/tmp
        php_admin_value upload_tmp_dir %home%/%user%/tmp
        php_admin_value session.save_path %home%/%user%/tmp
        php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f info@%domain$
    </Directory>
I have tried adding:-

Code: Select all

php_admin_value open_basedir %docroot%:%home%/%user%/tmp:/home/geofile
This did not work either (yes I did remake web and restart server)

I have been searching the forum and tried all sorts of fixes but it has not resolved the above problem. I have also restarted my server after each fix and rebuilt web templates.

This never happened with the old install of vesta it only since new install and different php (5.6) in Centos 6.8 that this has happened.

Thanks in advance for your help.

EDIT!!!!!!!!!!!

I solved the problem! And here is how I did it:-

I edited the default.stpl instead of the basedir.stpl because my sites use the 'default template' so basically I was editing the WRONG TEMPLATE!!! DUHHHHHH!!! <begin facepalm></end facepalm>

So I added:-

Code: Select all

php_admin_value open_basedir %docroot%:%home%/%user%/tmp:/home/geofile
to default.stpl and rebuilt web in admin and reboot server and all is working as it should :)