Installing OSQA on CentOS6

This is how to install OSQA from source on CentOS6. At the time I'm writing this document, there are no OSQA rpms. There is however a completely self-contained package at http://bitnami.org/stack/osqa, including Postgres, python, and all the rest, but that's a 32-bit installation. One of the requirements of an OSQA installation where I worked on this project is LDAP authentication. After wasting a few hours I decided that trying to integrate 32-bit LDAP into this distribution on a 64-bit system was more of a hassle than it was worth. Plus, this installation wasn't able to send email for some unknown reason.

OSQA is based on Django, which itself supports all the major databases. For simplicity, this note describes how to configure OSQA to use sqlite3.  If you're successful getting OSQA to work this way then it should be easy to get it to work with MySQL or Postgres.I've also chosen to describe how to install OSQA on a system on which it is the only web application being run. Again, if this simple approach is successful then you can easily modify the instructions to run OSQA as a virtual host.

To start off, make sure the version of CentOS6 you're running does not have SELinux enabled. Download Django from http:www.djangoproject.com/download/ . This note uses Django 1.3.1. Also, download OSQA itself from http://www.osqa.net/download .The current version of OSQA is called "Fantasy Island" and is version 0.9.9 Beta 3. This will probably change by the time you read this. Move the files you downloaded into the directory of your choice. This note uses /usr/local/src so all examples reflect this choice. The OSQA download extracts its contents into a directory that itself is called "fantasy-island-0.9.0-beta3". You must change this name into something that's an acceptable Python module name. I wasted several hours trying to figure out why my OSQA installation was failing, only to learn that it was using its directory name as a Python module.

Let's get started. First, make sure mod_wsgi is installed.

yum install mod_wsgi

Next, install some Python modules.

easy_install ElementTree Markdown html5lib

Now, extract and build Django

tar -zxvf Django-1.3.1.tar.gz
cd Django-1.3.1
python setup.py install
cd ..

Do the same thing for OSQA

tar -zxvf fantasy-island-0.9.0-beta3.tar.gz
mv fantasy-island-0.9.0-beta3 osqa
cd osqa
mkdir cache
chmod u+w log forum/upfiles

Copy the osqa.wsgi.dist file to osqa.wsgi and modify to match your installation location.

cp osqa.wsgi.dist osqa.wsgi

Using /usr/local/src as the installation location the contents of osqa.wsgi should be

import os
import sys
sys.path.append('/usr/local/src')
sys.path.append('/usr/local/src/osqa')
os.environ['DJANGO_SETTINGS_MODULE'] = 'osqa.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

In preparation for using sqlite3

mkdir db
chmod u+w db

Make sure apache owns everything

chown -R apache:apache .

Make a local version of the settings file

cp settings_local.py.dist settings_local.py

Then, modify it so that the lines with the following names are as shown. There will be other lines but they don't need to be modified. Make sure you change the "APP_URL" to match your hostname.

DATABASE_NAME = '/usr/local/src/osqa/db/osqa.db'
DATABASE_ENGINE = 'sqlite3'
TIME_ZONE = 'America/Los_Angeles'
APP_URL = 'http://your.server.com'
DISABLED_MODULES = ['books', 'recaptcha', 'project_badges', 'oauthauth', 'facebookauth']

Modify /usr/local/src/osqa/forum/utils/html.py so that the line

from django.template import mark_safe

becomes

from django.utils.safestring import mark_safe

And modify /usr/local/src/osqa/forum/urls.py so that

url(r'^%s(.*)' % _('nimda/'), admin.site.root),

becomes

url(r'^%s(.*)' % _('nimda/'), include(admin.site.urls)),

Now you're ready to create the OSQA database tables and the OSQA administrative user. To do this, run

python manage.py syncdb

You'll see some warning about depreciated Python features. Ignore these. You'll be asked for the name, password, and email address for the OSQA administrator.

Finally it's time to configure Apache. First create some directories

mkdir -p /var/run/wsgi
mkdir -p /var/python/eggs
mkdir /var/log/httpd/osqa

Again, make sure apache owns everything

chown -R apache:apache .

Now, add the following to the end of /etc/httpd/conf/httpd.conf

WSGISocketPrefix run/wsgi
WSGIPythonHome /usr
WSGIPythonEggs /var/python/eggs

ServerAdmin admin@your.server.com
DocumentRoot /usr/local/src/osqa/forum
ServerName localhost.localdomain

#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/ /usr/local/src/osqa/forum/skins/
Alias /upfiles/ /usr/local/src/osqa/forum/upfiles/
<Directory /usr/local/src/osqa/forum/skins>
        Order allow,deny
        Allow from all
</Directory>

#this is your wsgi script described in the prev section
WSGIScriptAlias / /usr/local/src/osqa/osqa.wsgi

CustomLog /var/log/httpd/osqa/access_log common
ErrorLog /var/log/httpd/osqa/error_log

Start apache

service httpd start

and go to http://localhost using your favorite browser. If all is well, you'll see the beautiful OSQA home page. If you don't, you can go to the usual error logs in /var/log/httpd. Anything OSQA specific is in /var/log/httpd/osqa.

Author: Jon Forrest

Labels

osqa osqa Delete
installation installation Delete
centos6 centos6 Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Nov 12, 2011

    Jordan Jambazov says:

    Thanks a lot for the nice guide to Jon Forrest!

    Thanks a lot for the nice guide to Jon Forrest!

  2. Jan 31

    RobertPattinson says:

    thanks for such a beautiful OSQA home page \ By Regards CW

    thanks for such a beautiful OSQA home page
    \

    By Regards
    CW