I am setting up a Django project in production. But I'm dealing with a weird permission issue. Before all, this is the structure of my project:


  • project

    • settings.py
    • urls.py
    • wsgi.py
    • ...
    • apps
      • app1
      • app2
      • app3
  • logs

  • static
  • ...

When deploying it, the site won't run unless www-data is user owner or group owner of project/project/apps (recursive) wether it's 775 or 550 permission. It has an HTTP 500 error

Weirdly, when I change permission to 777, and remove all ownership from www-data, I still have the same HTTP 500 error.

The usual error is an ImportError. It cannot import some modules/apps.

Now my question is why is that? At least with permission 777, it should run as www-data would anyway have full permissions on the folder project/project/apps

It looks as if Apache (www-data) just want to own the folder (whether it's at group level or user level)

How do you set permissions on django project folders when you deploy with Apache?


First thing HTTP 500 error is a common error can be caused by many factor, I doubt if it is a permission issue as then it might have 403 forbidden error. Can you please add error log into the question.

Import error comes into role in python/django when your file is unable to import some other file or application. This might also cause when the working directory of a python program is incompatible with the other files imported inside the project.

Like if i have a file in src/common/libraries/a.py and a file in src/common/helpers/a_helper.py

and in a.py from src.common.helper.a_helper import *

When i run above a.py from mypro/src/common/libraries it will show an import error while running the same program from mypro/ directory will run the program successfully.

The Django documentation is quite useful read this : https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/modwsgi/

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.