• Plesk Uservoice will be deprecated by October. Moving forward, all product feature requests and improvement suggestions will be managed through our new platform Plesk Productboard.
    To continue sharing your ideas and feedback, please visit features.plesk.com

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