[Fixed]-Setup django with WSGI and apache

8👍

What happens if you remove the Alias / directive?

8👍

Note that Alias and WSGIScriptAlias directives do not have the same precedence. Thus, they will not be processed in file order as written. Instead, all Alias directives get precedence over WSGIScriptAlias directives. Thus, it wouldn’t have mattered if the Alias for ‘/’ appeared after WSGIScriptAlias, it would still have taken precedence.

6👍

It works. I have no idea why, but it does.

For future reference:

It works because Apache processes alias directives in order, and uses the first match. It was always hitting Alias /, which will match anything, before WSGIScriptAlias.

From the mod_alias documentation:

First, all Redirects are processed before Aliases are processed, and therefore a request that matches a Redirect or RedirectMatch will never have Aliases applied. Second, the Aliases and Redirects are processed in the order they appear in the configuration files, with the first match taking precedence.

3👍

try following this tutorial – http://singlas.in/5-step-tutorial-for-using-django-with-apache-and-mod_wsgi/

you are trying to host apache /var/www/ folder and the Django app both at root (/). Since Alias directive takes precedence over WSGIScriptAlias, it is rendering apache directory.

you can try to host the django app at /app. Alternatively host the /var/www/ folder at a different location like /public

Leave a comment