python os.makedirs Error 13 permission denied - python

I have a server set up on apache.
So when i run it and i upload a few files from a different machine. The server crashes here..
os.makedirs('data/%d' % stat.id)
The server crashes and it gives me this error
[Errno 13] Permission denied: 'data'
I have googled it and looked at other posts, I tried, but nothing works.
I have tried changing the group and chmod, chown..

Apache was making a directory under root.
I had to change the directory and it works.
os.chdir('...')
And when i create directory, its fine.

Related

Why am I getting PermissionError [Errno 13] when attempting to write to log in Flask hosted by Apache?

I am running Flask 1.1.4 via Python 3.5.3, hosted via an Apache 2 server on Debian Stretch. I am attempting to log various messages from the program, using the python logging module. This works normally. However, if I restart the Apache server using sudo service apache2 restart, the Flask application errors out with PermissionError: [Errno 13] Permission denied: (log file name). Is this an issue anyone else has run into?
If it is not a permissions issue, this usually happens (happened to me a few times) if you are using a relative path for the log file.
The current working directory for an app running with mod_wsgi is not the directory the the app is in. If you are using a relative path for the log file you can try to use absolute path instead.
More info here: https://modwsgi.readthedocs.io/en/master/user-guides/application-issues.html#application-working-directory
It turns out that there was a cron process that was editing the ownership of all files in my log folder to root. Once the program was restarted and needed to re-obtain the file reference, it was unable to do so.

Write File Python

I have a python script I am running with a post request. The script is located in my cgi-bin and at the end of the script I am trying to upload a file to the /var/www/html/ folder and I am doing it like this
myFile= open("/var/www/html/file.html","w")
myFile.write("<html><body><p>test</p></body></html>")
myFile.close()
But I keep getting
<type 'exceptions.IOError'>: [Errno 13] Permission denied: '/var/www/html/file.html'
What is going wrong?
The error itself is already clear, your don't have enough permission to write to /var/www/html. It might be related the owner of the directory. If the owner is another user, then your current user don't have the write permission to the directory, the error would occur.

eb.exe deploy": Errno 13 Permission denied: './pagefile.sys'

I am compiling a website using TeamCity on a server and need to deploy the compiled website to AWS.
As my last build step, I use the Elastic Beanstalk CLI to deploy: "C:\Python34...\eb.exe deploy".
eb init has already been run...but whenever I run "eb deploy", (even when I run it from the command line in an empty directory--which should deploy a default project to AWS), an error appears saying:
Error: PermissionError :: [Errno 13] Permission denied: './pagefile.sys'
I have already run the command on my local machine without any problems; I receive the error on the server regardless of whether I am running the command line as an administrator.
I am wondering if this is a permissions issue with the server, or something else? I haven't been able to achieve much insight from the other questions, because they seem to have been solved on a case-by-case basis.
pagefile.sys is the Windows swap file.
It is a special file which cannot be written or manipulated. Whatever your command is doing you need to fix your command so it that doesn't touch this file and ignores it.

OSError errno 13 Permission Denied Python CGI os.listdir

I am executing os.listdir() from Python CGI script. Script executes from console with no problem but when it is called from the web interface I get OSError errno 13 Permission Denied. It is denying permission to files in a different directory /usr/local/bin/ I checked permission levels and even changed owner and group to apache. I Even added Apache Directory configurations to allow all in ssl.conf file. Any thoughts? Thank you all in advance for the guidance.

django - permission problem when uploading a file

I'm working on creating a form with which the user can upload an image and I get this error:
[Errno 13] Permission denied:
Can someone provide some guidance on what I would need to change (keeping in mind I'm running the development server on windows) for it to work? Is it something in settings.py or do I need to change the permissions of the directory that files are uploaded to?
[Errno 13] Permission denied is a Python OSError:
It is raised when a function returns a system-related error (not for illegal argument types or other incidental errors).
The number 13 means Permission denied, the user who launch your app doesn't have access in write to the folder where you want to upload.

Categories

Resources