0

I deployed a beta version of my django app to DigitalOcean and I am serving it using Apache and WSGI.

Everything works well include static files and 'get' media files(I saved it directly to DB), except uploading files. It shows 'Permission denied' error, with full directory like '/home/test/project/media/test.jpeg'.

I configured httpd-vhosts like this.

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com

    WSGIScriptAlias / /home/test/project/project/wsgi.py
    WSGIDaemonProcess example.com python-home=/home/test/project/.venv python-path=/home/test/project/project
    WSGIProcessGroup example.com

    Alias /static/ /home/test/project/frontend/build/static/ # react build dir

    <Directory /home/test/project/frontend/build/static>
        Require all granted
    </Directory>

    Alias /uploadImg/ /home/test/project/media/
    <Directory /home/test/project/media>
        Require all granted
    </Directory>

    <Directory /home/test/project/project>
    <Files wsgi.py>
        Require all granted
    </Files>
    </Directory>
</VirtualHost>

So httpd is running with daemon, and my directory 'media' is owned by root, 755. But the directory 'media' is symbolic link dir which located at '/home/test/'

I did many attempts to fix it but nothing works.. Thanks for all the responses

1 Answer 1

0

I solved it myself. My problem was about 'who runs the apache process' and 'who owned the dir'. It should be same user or group with writing authority. Hope someone who have problem with this was helpful.

Sign up to request clarification or add additional context in comments.

2 Comments

Hello, I'm facing the same PermissionError: [Errno 13] for WSGI Django app, served with Apache2. I've tried
Did you change permissions to a virtual environment ? I'm trying to do that with no results. Tried chmod and chown and chgrp for www-data. Are you referring to WSGIDaemonProcess or WSGIProcessGroup in apache2 site.conf ? Please any help ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.