Changes between Version 3 and Version 4 of django_apache_and_mod_wsgi
- Timestamp:
- Aug 19, 2007, 1:12:57 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
django_apache_and_mod_wsgi
v3 v4 5 5 == Installation == 6 6 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.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. [[BR]] 8 On that page you will find a link to precompiled windows binaries. 9 9 10 Apache and mod_wsgi application 10 == Configuration of Apache and mod_wsgi == 11 11 12 In this section I will take you trough an example, the django application is called dj_survey. 12 In 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". 13 13 14 The original urls.py is looking like this:14 The urls.py I used to serve the application with the Django built-in development server: 15 15 {{{ 16 16 from django.conf.urls.defaults import * … … 33 33 }}} 34 34 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 deuse "/" and not "\".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 use "/" and not "\". 36 36 httpd.conf 37 37 {{{ … … 43 43 }}} 44 44 45 This suppose that you createa folder named apache in your django project in this folder your should add the following files:45 This suppose that you have created a folder named apache in your django project in this folder your should add the following files: 46 46 47 47 * 08/16/2007 04:12 PM 1,082 apache_django_wsgi.conf … … 51 51 * 08/16/2007 04:33 PM 0 !__init!__.py 52 52 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_project53 __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 54 54 55 55 Like in the httpd.conf you should pay attention to the separator. You should use "/" and not "\" … … 94 94 95 95 #Calculate the path based on the location of the WSGI script. 96 apache_configuration= os.path.dirname( os.path.dirname(__file__))96 apache_configuration= os.path.dirname(__file__) 97 97 project = os.path.dirname(apache_configuration) 98 98 workspace = os.path.dirname(project) 99 sys.path.append(project)100 99 sys.path.append(workspace) 101 100 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. 103 102 sys.path.append('C:\\yml\\_myScript_\\dj_things\\web_development\\svn_views\\django_src\\trunk') 104 103 sys.path.append('C:\\yml\\_myScript_\\dj_things\\web_development\\svn_views\\django-registration') … … 109 108 }}} 110 109 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 {{{ 112 print >> sys.stderr, sys.path 113 }}} 114 115 In 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). 116 There 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. 113 117 114 118 {{{