• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Resolved Access file placed in another virtual host

Nicola

Basic Pleskian
Hi,
I have a php script, placed in virtual host 1, that has to download files placed in another virtualhost.
I try to download this file via http ("http://www.site1.com/file.pdf") or directly on the server ("/var/www/...") but I can not access to this file: the function used is "file_get_contents()".
I set the variables "allow_url_fopen" to "On", "open_basedir" to the path where placed the file and SELinux policies to permissive mode but nothing changed.
The strange thing is that the file is accessible via browser...someone have any idea?

Thanks in advance
 
You cannot "travel" from one virtual host to another, because of security.
If you want to do this, then you should create one domain and then inside of this space you can add a new domain, then you will have under the same virtual host and will work.
 
You can setup open_basedir and probably will work, but you will always have issues. My suggestion, if you want to do this, to move under same subscription and same vhosts. Then will be same FTP user, same place and you will have no issues.
 
Hello Ivalics,
if this is a security reaseon, why the old file not has problem? I'll explain: on the old server everything worked fine...when I migrated the data on the new server, the files already present are downloaded without problems (with file_get_contents()) instead the anomaly occurs with direct uploads to the new server.
This also appens with php file...if I try to connect to a php file created on new server I have the problem but when I try connect to a file created on old server all works fine.
 
Could be because from time to time (read version from version) PLESk improve security. Could be that on PLESk 11.x worked, but will not work on 12.x, or could be also mod_security which will block this, there is many reason, check your log file and that will help you a lot. But if is an open_directory issue, then you have 2 way. Add to PHP settings that folder where is the downloadable file or move one domain under another and will work as a charm.
An another solution could be to upload/download in PHP script via FTP.
 
My guess is that you old server ran mod_php and you had that folder set to 777.. which would have worked fine. New server is probably running FPM so can't write to the other folder.
 
In php-fpm mode you just need to fix folder rights and will work ok. 755 for folders and 644 for files.

cd /var/www/vhosts/yourdomain.com/httpdocs/

then

find ./ -type d -exec chmod 0755 '{}' \;
find ./ -type f -exec chmod 0644 '{}' \;
 
Between subdomains yes, but I recommend do it one by one. As I know there is also a tool in PLESK which will do this automatically for all domains, but I never used. Someone can confirm if

plesk repair web

will do this? (I think yes)
 
Back
Top