Configuring Django to work with apache 2.4

0 Tatrasiel R · April 18, 2015
Hey so I have thought about converting my server over to Django from PHP and I have used Apache as my httpd service. I seem to have a discrepancy between my Apache configurations and my Django project.

Can someone provide a fairly verbose amount of information on how Django should be configured to work with Apache?

I can provide current configurations and just to let you know I am running a Debian based flavour of Linux.

Post a Reply

Replies

Oldest  Newest  Rating
0 Tatrasiel R · April 18, 2015
ok well I figured this out... Apparently, Python upon creating the project doesn't completely set up $PATH for you.


I had to make this in my wsgi.py 



import sys
import os

"""
WSGI config for myproject project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
"""

# Added these following four lines to fix the path.
# I wonder if this could be handled from the Apache.conf itself.

base = os.path.dirname(os.path.dirname(__file__))
base_parent = os.path.dirname(base)
sys.path.append(base)
sys.path.append(base_parent)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

 I will add more documentation as I lost some valuable time doing this but, in the long run, I hope it helps others.
  • 1

Python

107,052 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator