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
os.environ['DJANGO_SETTINGS_MODULE'|'DJANGO_SETTINGS_MODULE'] = 'OSQA.settings'
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 [http://example.com/forum], if you like
<VirtualHost ...your ip...:80>
	ServerAdmin forum@example.com
	DocumentRoot /path/to/osqa-site
	ServerName example.com

	#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
	</Directory>

	#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(.*)$ [https://example.com/nimda$1] [L,R=301]
	</Location>
	CustomLog /var/log/httpd/OSQA/access_log common
	ErrorLog /var/log/httpd/OSQA/error_log
</VirtualHost>

#(optional) run admin interface under https
<VirtualHost ..your ip..:443>
	ServerAdmin forum@example.com
	DocumentRoot /path/to/osqa-site
	ServerName example.com
	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
</VirtualHost>
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.