Askbot is a Question and Answer (Q&A) forum whose design is inspired by StackOverflow and YahooAnswers and other similar projects (to lesser extent).

Askbot is written in Python on top of Django platform. Code of Askbot grew out of CNPROG project originally written by Mike Chen and Sailing Cai.

If you have any questions installing or tweaking askbot - please do not hesitate to ask at the forum or by email at admin@askbot.org.

Prerequisites

To install and run Askbot the following are required:

  • Python version 2.4 - 2.6 (Version 3 is not supported)
  • MySQL version 5

For the production deployment you will also need a webserver capable to run python web applications (see section Deployment).

Installation Instructions

To simplify future deployment, please make sure to use the same python interpreter for the installation and testing as the one assigned (or will be assigned) to the webserver.

If you already have easy_install on your system, then type:

easy_install askbot

If you are using the easy_install tool, make sure that it was also originally installed with the python interpreter mentioned above, otherwise use the second method:

Download the latest version of askbot, unzip and untar the archive and run:

python setup.py install

If you are planning to use askbot on Windows, please install mysql-python windows binary package manually.

Chances are that steps above will complete your installation. If so, then proceed to the Configuration section. Below are extra installation notes that cover some special cases.

To install in non-standard locations add parameter –prefix=/path/to/some/dir to both commands.

Askbot depends on about a dozen other packages. Normally those dependencies will be automatically resolved. However, if something does not go well - e.g. some dependency package site is not accessible, please download and install some of those things ( django-1.1.2, django-debug-toolbar, South, recaptcha-client, markdown2, html5lib, python-openid, django-keyedcache, django-threaded-multihost, mysql-python ) manually.

If any of the provided links do not work please try to look up those packages or notify askbot maintainers at admin@askbot.org.

Configuration

type:

startforum

and answer questions.

The startforum script will attempt to create necessary directories and copy files.

If you are creating a new Django project, you will need to edit file

In the case you are adding askbot to an existing Django project, you will need to merge askbot files settings.py and urls.py into your project files manually.

Within settings.py, at the very minimum you will need to provide correct values to:

DATABASE_NAME = ''
DATABASE_USER = ''
DATABASE_PASSWORD = ''

within single quotes - login credential to your mysql database. Assuming that the database exists, you can now install the tables by running:

python manage.py syncdb
python manage.py migrate forum

now run the development sever:

python manage.py runserver `hostname -i`:8000 #or use some other port number > 1024

hostname -i is a Unix command returning the IP address of your system, you can also type the IP manually or replace it with localhost if you are installing askbot on a local machine.

Your basic installation is now complete. Many settings can be changed at runtime by following url /settings.

If you choose to host a real website, please read section Deployment.

Deployment

Webserver process must be able to write to the following locations:

/path/to/django-project/log/
/path/to/django-project/askbot/upfiles

If you know user name or the group name under which the webserver runs, you can make those directories writable by setting the permissons accordingly:

For example, if you are using Linux installation of apache webserver running under group name ‘apache’ you could do the following:

chown -R yourlogin:apache /path/to/askbot-site
chmod -R g+w /path/to/askbot-site/forum/upfiles
chmod -R g+w /path/to/askbot-site/log

If your account somehow limits you from running such commands - please consult your system administrator.

Installation under Apache/mod_wsgi

Apache/mod_wsgi combination is the only type of deployment described in this document at the moment. mod_wsgi is currently the most resource efficient apache handler for the Python web applications.

The main wsgi script is in the file django.wsgi it does not need to be modified

Configure webserver

Settings below are not perfect but may be a good starting point:

#NOTE: the directory paths used here may be adjusted

#the following two directories must be both readable and writable by apache
WSGISocketPrefix /path/to/socket/sock
WSGIPythonEggs /var/python/eggs

#the following directory must be readable by apache
WSGIPythonHome /usr/local

#NOTE: all urs below will need to be adjusted if
#settings.FORUM_SCRIPT_ALIAS is anything other than empty string (e.g. = 'forum/')
#this allows "rooting" forum at http://example.com/forum, if you like

#replace with 127.0.0.1 with real IP address
<VirtualHost 127.0.0.1:80>
     ServerAdmin you@example.com
     DocumentRoot /path/to/django-project
     ServerName example.come

     #aliases to serve static media directly
     #will probably need adjustment
     Alias /m/ /usr/local/lib/python2.6/site-packages/askbot/skins/default/media/
     Alias /upfiles/ /path/to/django-project/askbot/upfiles/
     Alias /admin/media/ /usr/local/lib/python2.6/site-packages/django/contrib/admin/media/
     <DirectoryMatch "/path/to/django-project/askbot/skins/([^/]+)/media">
        Order deny,allow
        Allow from all
     </DirectoryMatch>
     <Directory "/path/to/django-project/askbot/upfiles">
        Order deny,allow
        Allow from all
     </Directory>
     #must be a distinct name within your apache configuration
     WSGIDaemonProcess askbot2
     WSGIProcessGroup askbot2
     WSGIScriptAlias / /path/to/django-project/django.wsgi
     #make all admin stuff except media go through secure connection
     <LocationMatch "/admin(?!/media)">
     RewriteEngine on
         RewriteRule /admin(.*)$ https://example.com/admin$1 [L,R=301]
         </LocationMatch>
     CustomLog /var/log/httpd/askbot/access_log common
     ErrorLog /var/log/httpd/askbot/error_log
     LogLevel debug
</VirtualHost>
#again, replace the IP address
<VirtualHost 127.0.0.1:443>
     ServerAdmin you@example.com
     DocumentRoot /path/to/django-project
     ServerName example.com
     <LocationMatch "^(?!/admin)">
         RewriteEngine on
         RewriteRule django.wsgi(.*)$ http://example.com$1 [L,R=301]
     </LocationMatch>
     SSLEngine on
     #your SSL keys
     SSLCertificateFile /etc/httpd/ssl.crt/server.crt
     SSLCertificateKeyFile /etc/httpd/ssl.key/server.key
     Alias /admin/media/ /usr/local/lib/python2.6/site-packages/django/contrib/admin/media/
     WSGIScriptAlias / /path/to/django-project/django.wsgi
     CustomLog /var/log/httpd/askbot/access_log common
     ErrorLog /var/log/httpd/askbot/error_log
</VirtualHost>

Database configuration

Database can be prepared via your hosting control panel, if available or can be created manually (provided that you have a mysql account with a sufficient privilege)

The relevant MySQL the commands are:

create database askbot DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;
grant all privileges on dbname.* to dbuser@localhost identified by 'dbpassword';

where dbname, dbuser and dbpassword should be replaced with the real values. MySQL will create a user with those credentials if it does not yet exist.

Automation of maintenance jobs

There are routine tasks that should be performed periodically from the command line. They can be automated via cron jobs

File askbot_cron_job has a sample script that can be run say hourly

The script currently does two things: (1) sends delayed email alerts and (2) awards badges. These two actions can be separated into two separate jobs, if necessary

Sitemap registration

Sitemap to your forum will be available at url /<settings.FORUM_SCRIPT_ALIAS>sitemap.xml e.g yoursite.com/forum/sitemap.xml or yoursite.com/sitemap.xml

Google will be pinged each time question, answer or comment is saved or a question deleted.

If you register you sitemap through Google Webmasters Tools Google will have be indexing your site more efficiently.