• 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

Python Permissions to Write Files in another web space on same server

Quotes

New Pleskian
I have a python script that generates images and is able to write them into a directory on the same web space

However, I would like the same script to write files into another directory located in the web space of another domain on the same server.

For example, script lives here...
/var/www/vhosts/domain1.com/httpdocs/scripts/myscript.py

this works...
/var/www/vhosts/domain1.com/httpdocs/scripts/images/

this fails...
/var/www/vhosts/domain2.com/httpdocs/web/images/

The directory structure already exists, so there is no need to create any new directories

I have tried setting permissions for the destination "images" directory to 777 and that didn't work.

Do I need to specify something within Plesk to enable it to write to another directory?
 
It failes because you don't have permission there, thus you will need to configure open_basedir in order for this to work.

In Control panel of domain, click on the domain name -> PHP Settings -> set open_basedir (path to this domain2.com images folder)

It should work.
 
Thank you MislavO

I updated the open_basedir settings (in domain1) to point to the destination directory (domain2) but it didn't work

I have another domain with custom open_basedir settings so I'm sure the syntax of the new setting was correct

I have checked my log files but can't see any reference to the error writing the files
 
Script should write something in the error.log file in case of a permission/open_basedir problem. If error log is empty then you need to check your application, debug it more futher.

Stupid question but, do you have under hosting settings under domain2 Python support enabled?

Are you running that script as a cronjob or ? Temporary workaround would be, if both of domain are yours to run that script as root user.
 
Python wasn't enabled on domain2... I updated and ran the python script on domain1 again and still no luck (even with open_basedir specified).

I've double checked the error logs, still nothing, so I will have to go back to the script author and see if there is a debug mode

I'm pretty sure you are on the right track and it is a permissions thing - the script works fine when running on domain1 and writing to domain1.
 
No solution found yet, but have obtained a verbose error message

IOError: [Errno 13] Permission denied:

Script is running via Cron, on Plesk Linux v11.5.30 and python v2.6
 
Back
Top