Changes between Version 3 and Version 4 of django_apache_and_mod_wsgi


Ignore:
Timestamp:
08/19/2007 01:12:57 PM (8 years ago)
Author:
yml
Comment:

Add information to print in error.log of apache

Legend:

Unmodified
Added
Removed
Modified
  • django_apache_and_mod_wsgi

    v3 v4  
    55== Installation ==
    66
    7 mod_wsgi can be downloaded from there: http://code.google.com/p/modwsgi/. There is an excellent procedure for installing it on windows there: http://code.google.com/p/modwsgi/wiki/InstallationOnWindows
    8 On that page you will find a link to precompiled binaries.
     7mod_wsgi can be downloaded from there: http://code.google.com/p/modwsgi/. There is an excellent procedure for installing it on windows there: http://code.google.com/p/modwsgi/wiki/InstallationOnWindows. [[BR]]
     8On that page you will find a link to precompiled windows binaries.
    99
    10 Apache and mod_wsgi  application
     10== Configuration of Apache and mod_wsgi  ==
    1111
    12 In this section I will take you trough an example, the django application is called dj_survey.
     12In this section I will take you trough an example, the django application is called dj_survey. This application is part of a project called "dj_project".
    1313
    14 The original urls.py is looking like this:
     14The urls.py I used to serve the application with the Django built-in development server:
    1515{{{
    1616from django.conf.urls.defaults import *
     
    3333}}}
    3434
    35 In httpd.conf you should load the mod_wsgi and include the file containing the configuration of your django application. The trap there is all the path should de use "/" and not "\".
     35In httpd.conf you should load the mod_wsgi and include the file containing the configuration of your django application. The trap there is all the path should use "/" and not "\".
    3636httpd.conf
    3737{{{
     
    4343}}}
    4444
    45 This suppose that you create a folder named apache in your django project in this folder your should add the following files:
     45This suppose that you have created a folder named apache in your django project in this folder your should add the following files:
    4646
    4747 * 08/16/2007  04:12 PM             1,082 apache_django_wsgi.conf
     
    5151 * 08/16/2007  04:33 PM                 0 !__init!__.py
    5252
    53 __Note__: There is a file called "!__init!__.py" in <PATH TO YOUR DJANGO PROJECT>/apache. In this case <PATH TO YOUR DJANGO PROJECT> is equal to c:\<LONG PATH>\dj_project
     53__Note__: There is a file called "!__init!__.py" in <PATH TO YOUR DJANGO PROJECT>/apache. In this case <PATH TO YOUR DJANGO PROJECT> is equal to c:\<LONG PATH>\workspace\dj_project
    5454
    5555Like in the httpd.conf you should pay attention to the separator. You should use "/" and not "\"
     
    9494
    9595#Calculate the path based on the location of the WSGI script.
    96 apache_configuration= os.path.dirname(os.path.dirname(__file__))
     96apache_configuration= os.path.dirname(__file__)
    9797project = os.path.dirname(apache_configuration)
    9898workspace = os.path.dirname(project)
    99 sys.path.append(project)
    10099sys.path.append(workspace)
    101100
    102 #Add the path to 3rd party django application and to django itself to the PYTHONPATH.
     101#Add the path to 3rd party django application and to django itself.
    103102sys.path.append('C:\\yml\\_myScript_\\dj_things\\web_development\\svn_views\\django_src\\trunk')
    104103sys.path.append('C:\\yml\\_myScript_\\dj_things\\web_development\\svn_views\\django-registration')
     
    109108}}}
    110109
    111 In this file you are defining the settings in our it is called: dj_project.apache.settings_production
    112 There is nothing special there except that  I am pointing to a special ulrs.py
     110__Note__: If you need to write something in "error.log" located in the following folder "<Your Apache Installation>\Apache2.2\logs" you can insert the line below in your WSGI file. In our example this file is called "dj_survey.wsgi". This method is very convenient to get the PYTHONPATH correct:
     111{{{
     112print >> sys.stderr, sys.path
     113}}}
     114
     115In this file you are defining the settings taht will be used by your Django application, in our example this file is called: "dj_project.apache.settings_production" (__Note__: ".py" is implicit and should not be added).
     116There is nothing special in that file except that  I am pointing to a special ulrs.py which reflect the configuration I am using in production.
    113117
    114118{{{
Back to Top