0

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

In start I didn't put files in /var/www/ but it was not working so I thought of moving things in it . and I added WSGIScriptAlias in mysite.conf but no change....
Did you reload Apache?
Take a look at the following tutorial for a working example of @DanielRoseman's explanation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.