• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Issue PHP opend_basedir restriction issues

michaelespinosa

New Pleskian
I need help getting PHP (v5.4.45) errors and permissions working properly after a server was migrated. Some of my sites need to access some files from another domain on the same server.

For example, /var/www/vhosts/planetrockcm.com/httpdocs/test.php might try to include /var/www/vhosts/rock.church/httpdocs/robots.txt using PHP include "/var/www/vhosts/domain1/httpdocs/robots.txt";

In Plesk (v17.5.3) I went into the domain > PHP settings > and modified the open_basedir settings to include /var/www/vhosts/rock.church/httpdocs/ (pic - Dropbox - Screenshot 2018-03-23 15.29.13.png)

I setup an example to show what I'm getting at phpinfo()

Here's what test.php has in it:

<?php

include "/var/www/vhosts/rock.church/httpdocs/robots.txt";

phpinfo();

?>
Here's the error's I'm getting: (pic - Dropbox - Screenshot 2018-03-14 12.31.04.png)

Warning: include(): open_basedir restriction in effect. File(/var/www/vhosts/rock.church/httpdocs/robots.txt) is not within the allowed path(s): (/var/www/vhosts/planetrockcm.com/:/tmp/:/var/www/vhosts/rock.church/httpdocs/) in /var/www/vhosts/planetrockcm.com/httpdocs/test.php on line 3

Warning: include(/var/www/vhosts/rock.church/httpdocs/robots.txt): failed to open stream: Operation not permitted in /var/www/vhosts/planetrockcm.com/httpdocs/test.php on line 3
It is saying there is an open_basedir restriction. The confusing part to me is that I actually added the path in manually as seen in the error itself.

open_basedir restriction in effect. File(/var/www/vhosts/rock.church/httpdocs/**robots.txt) is not within the **allowed path(s): (/var/www/vhosts/planetrockcm.com/:/tmp/:/var/www/vhosts/rock.church/httpdocs/)

I'm really grateful for any help getting this resolved or pointing me in the right direction. My host is saying they are not able to help.
 
Assuming this is a private server with no other clients, you could chmod the website folder 755 I suppose....
 
That seemed to get rid of the open_basedir restriction warning, but I am now getting:

Warning
: include(/var/www/vhosts/rock.church/httpdocs/robots.txt): failed to open stream: Permission denied in /var/www/vhosts/planetrockcm.com/httpdocs/test.php on line 3

@Mark Muyskens Thanks for helping with this! What do you suggest?
 

Attachments

  • Screenshot 2018-03-24 01.34.19.png
    Screenshot 2018-03-24 01.34.19.png
    48.1 KB · Views: 6
Last edited:
How about the file you're including? Let's chmod it to 755 as well....

It has been chmod to 755, but still yielding the same result. You can see it at phpinfo()

Warning: include(/var/www/vhosts/rock.church/httpdocs/robots.txt): failed to open stream: Permission denied in /var/www/vhosts/planetrockcm.com/httpdocs/test.php on line 3
Warning: include(/var/www/vhosts/rock.church/httpdocs/robots.txt): failed to open stream: Permission denied in /var/www/vhosts/planetrockcm.com/httpdocs/test.php on line 3
Warning: include(): Failed opening '/var/www/vhosts/rock.church/httpdocs/robots.txt' for inclusion (include_path='.:/opt/plesk/php/5.4/share/pear') in /var/www/vhosts/planetrockcm.com/httpdocs/test.php on line 3
 

Attachments

  • Screenshot 2018-03-24 04.04.44.png
    Screenshot 2018-03-24 04.04.44.png
    14.8 KB · Views: 7
Back
Top