• Introducing WebPros Cloud - a fully managed infrastructure platform purpose-built to simplify the deployment of WebPros products !  WebPros Cloud enables you to easily deliver WebPros solutions — without the complexity of managing the infrastructure.
    Join the pilot program today!
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.

Access outside httpdocs

T

tcreswick

Guest
I have a php file inside %domain%/httpdocs which is attempting to access files in a custom folder one level up; the exact php code is:

Code:
$lines = file('/var/www/vhosts/domain.com/files/auth.txt');

I have created a vhost.conf file which contains the following:

Code:
<Directory /var/www/vhosts/domain.com/httpdocs>
        php_admin_flag engine on
        php_admin_flag safe_mode off
        php_admin_value open_basedir "/var/www/vhosts/domain.com/httpdocs:/var/www/vhosts/domain.com/files:/tmp:."
</Directory>

I have run the
Code:
/usr/local/psa/admin/bin/websrvmng -a
command and restarted the apache service, but I am seeing the following PHP error:

Code:
Warning: file(/var/www/vhosts/domain.com/files/auth.txt) [function.file]: failed to open stream: Permission denied in /var/www/vhosts/domain.com/httpdocs/inc/auth.php on line 56

For testing purposes, I have recursively set chmod permissions to 777 on the folder, i.e.
Code:
chmod -R 777 /var/www/vhosts/domain.com/files

I appreciate that once this is working properly, these permissions should be set to 755 or similar.

Currently the "domain.com" folder listing is as follows:

Code:
drwxr-x--- 5 tsfiles psaserv 4096 Oct 16 12:14 anon_ftp
drwxr-xr-x 2 root    psaserv 4096 Oct 16 12:14 bin
drwxr-x--- 3 tsfiles psaserv 4096 Oct 16 12:14 cgi-bin
drwxr-x--- 2 root    psaserv 4096 Oct 16 14:03 conf
drwxr-xr-x 2 root    psaserv 4096 Oct 16 12:14 error_docs
drwxrwxrwx 4 root    psaserv 4096 Oct 16 13:45 files
drwxr-x--- 8 tsfiles psaserv 4096 Oct 16 12:38 httpdocs
drwxr-x--- 2 tsfiles psaserv 4096 Oct 16 12:17 httpsdocs
drwxr-x--- 2 root    psaserv 4096 Oct 16 12:14 pd
drwx------ 2 tsfiles root    4096 Oct 16 12:14 private
dr-xr-x--- 7 root    psaserv 4096 Oct 16 12:14 statistics
drwxr-xr-x 2 root    psaserv 4096 Oct 16 12:14 subdomains
drwxr-xr-x 2 root    psaserv 4096 Oct 16 12:14 web_users

You will note that the owner of the "files" folder is set to root at the moment. I have tried setting this to "tsfiles" (the domain user), but this hasn't worked either.

What am I missing here?

Many thanks in advance
 
Hi,

First thing: apache should be restarted after making changes in configuration so I would recommend running:
websrvmng -v -a

another thing you should try it setting owner:group of file to apache:apache as php run under apache user.
 
I had already tried both of these things, although I was restarting apache via the init.d script.

Just in case I was going mad, I've just changed this and tried again with the same error.
 
Have just resolved this issue as being SELinux; another administrator had enabled this on the system where we usually leave it disabled.
 
Back
Top