OSQA on Ubuntu with LDAP Authentication

OSQA (open Source Q & A ) is a stackoverflow clone and is a fantastic tool to kick-start a thriving community within technology firms. This system can also be extended to customers with minor tweaking and adequate control.

This blog will cover installing OSQA on Ubuntu Server. It is quite an exhaustive setup and can take about an hour before it can be used and tested.


  1. Ubuntu Server 12.04.02, fully patched
  2. MySQL Server 5.5
  3. Apache Web Server
  4. Subversion
  5. Python Framework
  6. Django framework
  7. OSQA source code

Setting Up

  1. Create a user on the system called as osqa. The source code will be downloaded in the home directory in the folder name osqa-server. We shall use this path as Document Root while configuring a virtual host on apache
  2. Installing the frameworks and pre-requisites
    • sudo apt-get install subversion apache2¬†libapache2-mod-wsgi mysql-server-5.5 phpmyadmin python python-mysqldb python-django python-openid python-html5lib python-markdown python-django-debug-toolbar sphinxsearch python-pip python-ldap python-setuptools
    • sudo pip install South django-sphinx
  3. Downloading the OSQA from the home directory of the osqa user
  4. Configuring OSQA – Go in the osqa-server directory and run the following commands
    • sudo nano /home/osqa/osqa-server/osqa.wsgi (paste the following content and then save)
    • import os
      import sys
      os.environ['DJANGO_SETTINGS_MODULE'] = 'osqa-server.settings'
      import django.core.handlers.wsgi
      application = django.core.handlers.wsgi.WSGIHandler()
    • Create Virtual Host and enable the site
      • sudo nano /etc/apache2/sites-available/osqa (paste the following content and save). After you have saved the content, you must enable the virtual host (sudo a2ensite osqa) and restart apache (sudo service apache2 restart)
      • # Must be readable and writable by apache
        WSGISocketPrefix ${APACHE_RUN_DIR}
        #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 *:80>
            ServerAdmin abc@yourdomain.com
            DocumentRoot /home/osqa/osqa-server
            ServerName osqa.yourdomain.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/ "/home/osqa/osqa-server/forum/skins/"
                <Directory "/home/osqa/osqa-server/forum/skins">
                        Order allow,deny
                        Allow from all
            Alias /upfiles/ "/home/osqa/osqa-server/forum/upfiles/"
            <Directory "/home/osqa/osqa-server/forum/upfiles">
                Order deny,allow
                Allow from all
            #this is your wsgi script described in the prev section
            WSGIScriptAlias / /home/osqa/osqa-server/osqa.wsgi
            CustomLog ${APACHE_LOG_DIR}/osqa.access.log common
            ErrorLog ${APACHE_LOG_DIR}/osqa.error.log
    • Create the database
      • Log in to phpmyadmin and create a database and a user. I have used osqa as the name of the database and osqa as name of the user who has full access on the osqa database only.
      • if you are comfortable using a command line, feel free to create users and database in mysql in a convenient way known to you
    • Setting up OSQA application – From the osqa-server directory
      • cp settings_local.py.dist settings_local.py
      • nano settings_local.py
      • Enter the details for the following in the above file at relevant places
        • DATABASE_NAME = 'osqa'
          DATABASE_USER = 'osqa'
          DATABASE_PASSWORD = 'osqa123'
          APP_URL = 'http://osqa.yourdoamin.com'
        • save the file and exit
    • Populate database – From inside the osqa-server directory run the below two commands
      • sudo python manage.py syncdb --all

        You will be prompted to create a new “super user.”¬† You should promptly answer “NO”.¬† Once you get your site running, create a new user through the normal OSQA account creation process and that will be your super user.

      • sudo python manage.py migrate forum --fake
    • Grant Apache permissions to OSQA Files
      • sudo chmod -R g+w /home/osqa/osqa-server/forum/upfiles
        sudo chmod -R g+w /home/osqa/osqa-server/log
      • chmod 666 /var/www/osqa/osqa-server/log/django.osqa.log
    • Restart Apache – sudo service apache2 restart
  5. You are Live – by going to your url : http://osqa.yourdomain.com ( I am assuming you are making the necessary DNS entries or making changes in the host files of your local computer)
  6. While logging in for the first time, you should create a new user. That user will become the super user. Go to the dashboard and explore the various settings especially for email configuration, sidebars content, custom CSS, LDAP authentication etc.

Cheers & Enjoy. Like the post if you think this has worked for you


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s