I have a django application that actually works perfectly underneath the django development server. I am attempting to implementing it in apache2.2 while using mod_wsgi and that i have errors.
Within the httpd.conf file I "mounted" my application underneath the root /myapp using:
WSGIScriptAlias /myapp /home/path_to_my_app/apache_conf/django.wsgi
I have adopted the conventional indication to organize django.wsgi. Now, I'm able to achieve the primary page template of my application however it appears to possess redirection errors. The "/myapp" root isn't placed instantly on ULRs redirection demands. Request in the primary page template with a modules in sights.py via web addresses.py can't be properly shipped.
apache error log:
127.0.0.1 - - [21/Feb/2011:16:11:44 +0100] "GET /myapp/ HTTP/1.1" 200 1795 127.0.0.1 - - [21/Feb/2011:16:11:46 +0100] "GET /api/dir HTTP/1.1" 404 205
"/api/dir" does not exist, it ought to be matched up from the pattern in web addresses.py, but id does not
I have spent a lot more than a couple of days by using it, please can somebody help?
It seems you're missing several things out of your apache config:
Within the working config for my server I've:
# tell apache where to find the wsgi script. WSGIScriptAlias / "/home/path_to_my_app/wsgi/my.settings.wsgi" # turn on auto-reload in WSGI WSGIScriptReloading On WSGIReloadMechanism Process # assign a process to a process group WSGIDaemonProcess djangoapps processes=10 threads=1 maximum-requests=500 display-name=my-wsgi WSGIProcessGroup djangoapps
Your WSGIScriptAlias lines are correct but you have to tell wsgi how you will run the application. You're probably getting 404's because there's not really a WSGIDaemonProcess line to inform the WSGI handler working together with your process.
http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives may well be a useful reference.
Finally I discovered the mistake. It wasn't attached to httpd.conf file but to how Web addresses are specified both to django web addresses.py file and also to templates.
When I mounted myapp in by doing this:
WSGIScriptAlias /myapp my_path_to_wsgi_module/django.wsgi
I had been thinking that Web addresses specified by django template files should carry a preliminary slash, such as this:
It results that in by doing this the applying works only on django development server but this is not on apache.
Rather if you are using Web addresses without initial slash like:
The application works properly both on django development server as well as on apache!
You have to stay away from beginning slashes even on pattern matching of django web addresses.py file:
such as this:
and never such as this:
Maybe it is really an apparent factor for expert django customers but when you are novice much like me, this will make you loose some time since it is a tough problem to become detected.