AskBot

This details my experience setting up AskBot on Ubuntu

Python PIP and postgres
 * 1) Requirements ###

sudo apt-get install python-pip postgresql-9.1 postgresql-server-dev-9.1 build-essential python-dev libapache2-mod-wsgi

sudo pip install psycopg2


 * 1) Setup Postgres ###

Create a user and database for AskBot

Log into postgres:

sudo -u postgres psql

Using the postgres command line interface:

create role askbot with createdb login encrypted password 'askbot_pass';

create database askbot_db with owner=askbot;

Then edit file /etc/postgres/8.4/main/pg_hba.conf and add a line as the first non-comment line or near, to make sure that this rule takes precedence:

local askbot_db askbot md5

Then restart the database server (probably as root user), the command may be:

/etc/init.d/postgresql restart


 * 1) Install AskBot ###

Install the AskBot software

sudo pip install askbot

Create a directory to hold the AskBot server. Put this in a directory accessible by apache

mkdir answers; cd answers

Setup AskBot

ask-bot setup

When you install Askbot the first time and any time you upgrade the software, run these two commands. When the script asks you if you want to create a superuser, answer no. By default Askbot sets admin status(superuser) for the first user created automatically but also supports this form.

python manage.py syncdb

python manage.py migrate askbot

python manage.py migrate django_authopenid

Edit `settings.py`, and comment out this line

'askbot.middleware.locale.LocaleMiddleware',

Start the server:

python manage.py runserver `hostname -i`:8000

Use your web broswer to go to `hostname:8000`, and create a user. This will become the default admin account.


 * 1) Setup AskBot for use with Apache ###

Static media must be collected into a single location with a command:

python manage.py collectstatic

Edit `settings.py`, and change STATIC_URL to:

STATIC_URL = '/static/'

There are several options on where to put the static files - the simplest is a local directory, but it is also possible to use a dedicated static files storage or a CDN, for more information see django documentation about serving static files.

Webserver process must be able to write to the following locations within your project:

chown -R yourlogin:www-data answers

chmod -R g+w answers/askbot/upfiles

chmod -R g+w answers/log


 * 1) Setup Apache ###

In `/etc/apache2/mods-enabled`:

sudo ln -s ../mods-available/rewrite.load sudo ln -s ../mods-available/ssl.load sudo ln -s ../mods-available/ssl.conf

Create an SSL certificate for the webserver. The "Common Name" parameter, asked for in the second command, should be gazebosim.org.

sudo mkdir /etc/apache2/ssl

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

Create a log directory

sudo mkdir /var/log/askbot

Add a ANAME record to your DNS record on your domain registration site for "answers".

Add the following to `/etc/apache2/sites-enabled/000-default`:

 ServerAdmin gazebosim@gmail.com DocumentRoot /var/www/answers ServerName answers.gazebosim.org #aliases to serve static media directly #will probably need adjustment Alias /static/ /var/www/answers/static/ Alias /upfiles/ /var/www/answers/askbot/upfiles/  Order deny,allow Allow from all   Order deny,allow Allow from all  #must be a distinct name within your apache configuration WSGIDaemonProcess www-data WSGIProcessGroup www-data WSGIScriptAlias / /var/www/answers/django.wsgi #make all admin stuff except media go through secure connection  RewriteEngine on           RewriteRule /admin(.*)$ http://gazebosim.org/answers/admin$1 [L,R=301]  CustomLog /var/log/askbot/access_log common ErrorLog /var/log/askbot/error_log LogLevel debug  # again, replace the IP address  ServerAdmin you@example.com DocumentRoot /var/www/answers ServerName gazebosim.org  RewriteEngine on           RewriteRule django.wsgi(.*)$ http://gazebosim.org$1 [L,R=301]  SSLEngine on         #your SSL keys SSLCertificateFile /etc/apache2/ssl/apache.crt SSLCertificateKeyFile /etc/apache2/ssl/apache.key Alias /admin/media/ /usr/local/lib/python3.2/dist-packages/django/contrib/admin/media/ WSGIScriptAlias / /var/www/answers/django.wsgi CustomLog /var/log/askbot/access_log common ErrorLog /var/log/askbot/error_log 

Restart the Apache server:

sudo /etc/init.d/apach2 restart