I think my apache2 server is close to being set up but it’s still returning a 500 error. Here is my .wsgi file:
import os, sys
#path to directory of the .wsgi file ('apache/')
wsgi_dir = os.path.abspath(os.path.dirname(__file__))
#path to project root directory (parent of 'apache/')
project_dir = os.path.dirname(wsgi_dir)
sys.path.append(project_dir)
project_settings = os.path.join(project_dir, 'settings')
os.environ['DJANGO_SETTINGS_MODULE'] = 'ecomstore.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
Here is my virtualhost file:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin admin@site.com
ServerName www.site.com
ServerAlias site.com
Alias /static /home/ecomstore/static
DocumentRoot /home/ecomstore
WSGIScriptAlias / /home/ecomstore/apache/ecomstore.wsgi
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
Here is my server restart:
sudo /etc/init.d/apache2 restart
* Restarting web server apache2
[Sun Apr 08 02:47:31 2012] [warn] module wsgi_module is already loaded, skipping
... waiting ..........[Sun Apr 08 02:47:42 2012] [warn] module wsgi_module is already loaded, skipping
...done.
However, even though I get no errors with mod-wsgi configuration on the restart, I still get the 500 Internal Server error mentioned before. Is there anything I’m missing?
You would need to look at the Apache error logs from when you made the request and not when you did the restart.
One source of problems is that sys.path does not include the parent directory of the project directory which would be necessary because of what you set DJANGO_SETTINGS_MODULE to. Go read about this requirement in:
http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
and fix it.
Beyond that, you need to work out whether it is an Apache 500 page or a Django one. If it is a Django one, then turn on DEBUG in Django settings file and restart Apache so you get a full error shown in browser. Turn off DEBUG when you have resolved.