aniket
aniket

Reputation: 95

Running django webapp on apache using mod_wsgi

I am new to working with apache and mod_wsgi. But I do have little experience in django, so from some tutorials I tried to run django app through apache webserver using mod_wsgi.
I created mysite in /var/www/
then in mysite/application I created application.wsgi ...

import os
import sys

sys.path.append('/var/www/mysite/application')

os.environ['PYTHON_EGG_CACHE'] = '/var/www/mysite/.python-egg'

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

and in /etc/httpd/sites-available I created file named mysite.conf ...

<VirtualHost *:80>
   ServerName mysite.com
   ServerAdmin [email protected]
   ServerAlias mysite.com
   DocumentRoot /var/www/mysite/   
<Directory /var/www/mysite>
Options FollowSymLinks
AllowOverride None
  Order allow,deny
  Allow from all
  SetEnv DJANGO_SETTINGS_MODULE mysite.settings
</Directory>
WSGIDaemonProcess mysite processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup mysite
</Virtualhost>

Then I ran a2ensite mysite.conf, didn't showed any error.
Then in /etc/httpd/hosts/ I added one line my-ipddress mysite.com
I gave permission chmod 777 to all the above files and to folder /var/www/mysite. Now when I open mysite.com on browser I see apahce's default page nothing from django.
I am using fedora 21.

Upvotes: 0

Views: 299

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599450

You haven't put in anything in that configuration to serve your Django site via WSGI: you're missing the WSGIScriptAlias line (see the documentation:

WSGIScriptAlias /  /var/www/mysite/mysite/wsgi.py

Note that you shouldn't really be putting things in /var/www; and also you shouldn't need to create your own WSGI file, Django creates one for you when you create a project.

Upvotes: 1

Related Questions