Setting Up OSQA for Apache

Prepare WSGI Script

First you will need to make a file that is readable by your webserver with the following content:

WSGI Script
import os
import sys

sys.path.insert(0,'/one/level/above') #insert to make sure that forum will be found
sys.path.append('/one/level/above/OSQA') #maybe this is not necessary
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

The insert method is used for the path because if the forum directory name is the same as some other Python module you will see strange errors. For example, using the name "test" is not a good idea since there is already a module with such name.

Configure Webserver

Your webserver's settings file should be something like the text below. This may not be perfect, but it is a good starting point

Apache Config
WSGISocketPrefix /path/to/socket/sock #must be readable and writable by apache
WSGIPythonHome /usr/local #must be readable by apache
WSGIPythonEggs /var/python/eggs #must be readable and writable by apache

#NOTE: all urs below will need to be adjusted if
#settings.FORUM_SCRIPT_ALIAS !='' (e.g. = 'forum/')
#this allows "rooting" forum at [], if you like
<VirtualHost ...your ip...:80>
	DocumentRoot /path/to/osqa-site

	#run mod_wsgi process for django in daemon mode
	#this allows avoiding confused timezone settings when
	#another application runs in the same virtual host
	WSGIDaemonProcess OSQA
	WSGIProcessGroup OSQA

	#force all content to be served as static files
	#otherwise django will be crunching images through itself wasting time
	Alias /m/ /path/to/osqa-site/forum/skins/
	Alias /upfiles/ /path/to/osqa-site/forum/upfiles/
	<Directory /path/to/osqa-site/forum/skins>
		Order allow,deny
		Allow from all

	#this is your wsgi script described in the prev section
	WSGIScriptAlias / /path/to/osqa-site/osqa.wsgi

	#this will force admin interface to work only
	#through https (optional)
	#"nimda" is the secret spelling of "admin" ;-)
	<Location "/nimda">
		RewriteEngine on
		RewriteRule /nimda(.*)$ [$1] [L,R=301]
	CustomLog /var/log/httpd/OSQA/access_log common
	ErrorLog /var/log/httpd/OSQA/error_log

#(optional) run admin interface under https
<VirtualHost ..your ip..:443>
	DocumentRoot /path/to/osqa-site
	SSLEngine on
	SSLCertificateFile /path/to/ssl-certificate/server.crt
	SSLCertificateKeyFile /path/to/ssl-certificate/server.key
	WSGIScriptAlias / /path/to/osqa-site/osqa.wsgi
	CustomLog /var/log/httpd/OSQA/access_log common
	ErrorLog /var/log/httpd/OSQA/error_log
	DirectoryIndex index.html
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.