0

I have a python/flask app running on apache server on a VPS running ubuntu 16.04.

When accessed from web, the app gives "internal server error" when trying to make a folder (called "organizations") inside /var/www/FlaskApp/FlaskApp. The exact error from Apache logs is this:

PermissionError: [Errno 13] Permission denied: 'organizations'

I did set permission of this folder (and folders above it) to 777. The permission denied error still persists. (yes, I know I shouldn't use 777. This is just a test server. And I will switch it back to 755 or 775 as soon as I figure out what the issue is)

I have tried to play around with other possible permission settings. I have tried setting the user 'www-data' as the owner of the folder using chown. Ive tried setting the ownerhsip of www-data using groups. Nothing seems to work.

If it is any use, im using Ubuntu 16.04 on a VPS, with apache2 serving a Python3/Flask application. The permission denied error occurs when the flask application tries to create a folder called "organizations" inside /var/www/FlaskApp/FlaskApp

Flask App permissions are set to 777, as are permissions of all folders above it. I asked this question on stack overflow, they said this would be a better forum to post it.

0

Okay so I figured out the issue. Answering for anyone else that may face it. The permission issue was probably not from linux. It was from Apache's own security measures.

Basically the folder I was trying to write to was not explicitly added to list of directories in the .conf file, so it wasn't recognized by apache. If you are facing this issue, open the YourAppName.conf file in Apache (usually in /etc/apache2/sites-available/YourAppName.conf>

Add the following lines to it before the '</VirtualHost>' :

    <Directory /var/www/YourAppName/YourDirectory/>
        Order allow,deny
        Allow from all
    </Directory>

YourDirectory will now be accessible for Apache and you will be able to read from and write to it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.