I've a django app that works perfectly under the django development server. Now I'm trying to run it under apache2.2 using the mod_wsgi.
In the httpd.conf file of apache I've added:
<IfModule wsgi_module>
WSGIScriptAlias /index my_path_to_wsgi_modules/django.wsgi
</IfModule>
and the django.wsgi module contains all the basic configuration as explained in django documentation: http://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/
Unfortunately when I run the server and try to access the main page I obtain the template page but without variable data in it. The server log says:
[Fri Feb 18 13:50:33 2011] [error] [client 127.0.0.1] File does not exist: /usr/local/apache2/htdocs/api, referer: http://127.0.0.1/example/
As I said before the strange thing is that the same code works perfectly under django development server. I'm new in programming web app, please, can anybody help?
My django.wsgi file looks like this:
import os import sys
from os.path import sep
basepath = '/home/example/WorkSpace/examplews/src'
sys.path.append(basepath)
sys.path.append('/home/example/WorkSpace/examplews/src/examplews')os.environ['DJANGO_SETTINGS_MODULE'] = 'examplews.settings'
import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()
And my httpd.con file, like this:
ServerRoot "/usr/local/apache2"
Listen 80
LoadModule wsgi_module modules/mod_wsgi.so
User apache
Group apacheServerAdmin [email protected]
DocumentRoot "/usr/local/apache2/htdocs"
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all</Directory>
<Directory "/usr/local/apache2/htdocs">
Options Indexes FollowSymLinksAllowOverride None
Order allow,deny
Allow from all
</Directory>
<IfModule dir_module>
DirectoryIndex index.html index.php index.sh default.jsp</IfModule>
<FilesMatch "^\.ht">
Order allow,deny
Deny from all
Satisfy All</FilesMatch>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio</IfModule>
CustomLog "logs/access_log" common
</IfModule>
<IfModule alias_module>
</IfModule>
<IfModule cgid_module>
</IfModule>
<IfModule wsgi_module>
WSGIScriptAlias /main /home/example/WorkSpace/examplews/src/examplews/apache_conf/django.wsgi</IfModule>
<Directory "/home/example/WorkSpace/examplews/src/examplews/apache_conf">
Order allow,deny
Allow from all</Directory>
DefaultType text/plain
<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin</IfModule>
/usr/local/apache2/htdocs/api
actually exist? Maybe something else in Apache is misconfigured. – Evan Porter