How to Set Up for Apace and Mod_wsgi

88 views
Skip to first unread message

Jon Blake

unread,
Sep 3, 2012, 1:01:17 AM9/3/12
to django...@googlegroups.com
I've worked through parts 1 and 2 of the tutorial using the development server, and I have reviewed the doco on how to use Django with Apache and mod_wsgi. I want to trial a production environment on my Fedora 14 dev box, but the provided instructions assume some familiarity with configuring the Apache environment.

I have Apache/2.2.17 (Unix) installed on my development box and I have installed package mod_wsgi-3.2-2.fc14 (x86-64), but I'm not sure where to go from here. Can anyone point me to a a concrete example of file edits (eg, httpd.conf, wsgi.conf) I need to do to set up Apache and mod_wsgi to serve my application? I have a path to the application package, and I want URL http://localhost/polls/ to run it.

Michael Crawford

unread,
Sep 3, 2012, 1:05:51 AM9/3/12
to django...@googlegroups.com
http://eddychan.com/post/18484749431/minimum-viable-ops-deploying-your-first-django-app-to

Have a look at this post.   I followed it friday and now have a working django install on ubuntu.  Steps should be almost the same for fedora.

Mike


On Sep 3, 2012, at 1:01 AM, Jon Blake <jc.b...@gmail.com> wrote:

I've worked through parts 1 and 2 of the tutorial using the development server, and I have reviewed the doco on how to use Django with Apache and mod_wsgi. I want to trial a production environment on my Fedora 14 dev box, but the provided instructions assume some familiarity with configuring the Apache environment.

I have Apache/2.2.17 (Unix) installed on my development box and I have installed package mod_wsgi-3.2-2.fc14 (x86-64), but I'm not sure where to go from here. Can anyone point me to a a concrete example of file edits (eg, httpd.conf, wsgi.conf) I need to do to set up Apache and mod_wsgi to serve my application? I have a path to the application package, and I want URL http://localhost/polls/ to run it.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Ai8swKtJnooJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Jon Blake

unread,
Sep 3, 2012, 2:36:56 AM9/3/12
to django...@googlegroups.com
Thanks, Mike, that fills in the gaps.

Eddy Chan's notes discusses file apache/django.wsgi. This appears somewhat similar to wsgi.py in my project package - how do these two files relate to each other? And the entries in httpd.conf - they can go pretty well anywhere?

Eddy's notes refer to installing Apache2, along with libapache2-mod-wsgi. Is libapache2-mod-wsgi something different from the mod_wsgi 3.2 package I have already installed?

TIA, Jon

Michael Crawford

unread,
Sep 3, 2012, 2:46:39 AM9/3/12
to django...@googlegroups.com
Basically the entry in the httpd.conf file points to the dejango.wsgi file.  Instead of apache/django.wsgi, point it to the location of yours.  I did the same since django now creates a default wsgi file when you create the project.   

Those entries can go anywhere in the file as long as they are not embedded in any other tags.

Those mod wsgi modules are probably the same.   In my version the logs for the module are written to the standard apache error log so you might have a look in there if it doesn't start up correctly.

It sounds like your version of apache uses the httpd.conf file for turning the modules on and off.  If I remember correctly from configuring mod_php in the past there may be something you have to do to actually turn the mod on in your particular configuration.   In ubuntu it doesn't use the conf file for this purpose, the mere presence of the module in the appropriate place turns it on.   If it doesn't appear to be turning on, I would suggest googling how to turn on mod_php as it should be the same type of thing I would assume.   

Mike


To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Jeuh5iHKhScJ.

Jon Blake

unread,
Sep 3, 2012, 2:55:23 AM9/3/12
to django...@googlegroups.com
Thanks, Mike. I'll get back to this next Friday. Assistance much appreciated.

Jon

Jon and Chiarina Blake

unread,
Sep 7, 2012, 2:43:09 AM9/7/12
to django...@googlegroups.com
OK, back to this. I'm confused. I've read Eddy Chan's article, which refers to the modwsgi Integration With Django article. Eddy's article indicates he has edited /etc/httpd/conf.d/wsgi.conf and created apache/django.wsgi as per instructions in the article. On reading the article, it's not clear (to this reader) what goes where.

Are you able to supply example contents of files wsgi.conf and django.wsgi?

TIA,
  Jon

Jon Blake

unread,
Sep 13, 2012, 1:28:02 AM9/13/12
to django...@googlegroups.com
I'm not making any progress on this. I have redone part 1 of the Django 1.4 tutorial, and it all works nicely with my Oracle back-end database and the development server. I'm now trying to progress this app to be served by Apache + mod_wsgi. After starting Apache, command  httpd -M lists wsgi_module (shared), and syntax OK. URL http://localhost/ shows the expected Apache test page.

I have added directive
WSGIScriptAlias / /home/jon/djangodemo/mysite/mysite/wsgi.py to /etc/httpd/conf/httpd.conf
as per one example of setting up a production site server I have found, and restarted Apache. I've made no changes to my app's wsgi.py module at this point. Now, URL http://localhost/ displays a "500 Internal Server Error" page. The Apache error_log includes line:
ImportError: Could not import settings 'mysite.settings' (Is it on sys.path?): No module named mysite.settings

Any suggestions on how to get this working? There are a number of articles out there on how to set up a Django app for serving by Apache + mod_wsgi, with different instructions - confusing. I'm after a the simplest approach on to how to get my Django tutorial app running from a production server.

Any advice appreciated! My background is Oracle DBA/development + Python. Very little experience with configuring Apache.

Regards,
  Jon
Reply all
Reply to author
Forward
0 new messages