Home > Software engineering >  Uploading files show permission denied (CentOS7 Apache mod_wsgi django)
Uploading files show permission denied (CentOS7 Apache mod_wsgi django)

Time:04-18

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

CodePudding user response:

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.

  • Related