Ask Your Question

How to setup AskBot with virtualenv?

asked 2011-05-30 01:52:57 -0500

Has anyone try virtualenv with AskBot?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2011-05-30 02:23:30 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >100 is welcome to improve it.

My rough step to step guide

There are still security risks and other non-functional settings. Please help to make it better. Currently, that is the only way for me to avoid 500 internal server error. Assuming my website name is


cd /home/deals/howtox    
virtualenv --no-site-package virtpy    
source virtpy/bin/activate

Then, I followed the instruction here:

pip install askbot

Then,set up mysql db user and pass, and then

create database howtox DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;


startforum forum
python syncdb
python migrate askbot
python migrate django_authopenid

The key is the order of sys.path in django.wsgi file. An "egg-cache" dir is also needed. The following file is working:

import os
import sys

# prev sys path
prev_sys_path = list(sys.path)

import site

# Avoid error msg
import os

current_directory = os.path.dirname(__file__)
parent_directory = os.path.dirname(current_directory)
module_name = os.path.basename(current_directory)


# reorder sys.path so new dir show up first
new_sys_path = [p for p in sys.path if p not in prev_sys_path]
for item in new_sys_path:
sys.path[:0] = new_sys_path

os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % module_name
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

In the end, I have the following directory setup:

- /home/deals/howtox
-- forum (django.wsgi is under this dir)
-- virtpy
- /var/www/
-- egg-cache

To make it complete. I am also throwing in my apache config file - /etc/apache2/sites-available/ Please note this is incomplete (static file is not working), but at least it is not giving 500.


    #Rewrite URL
#   RewriteEngine On
#   RewriteCond %{HTTP_POST} ^
#   RewriteRule (.*)$1 [R=301,L]

    ErrorLog /var/log/apache2/howtox_com_error.log
    CustomLog /var/log/apache2/howtox_com_access.log combined

    #Setup mod_wsgi
    WSGIScriptAlias / /home/deals/howtox/forum/django.wsgi

    <Directory /home/deals/howtox/forum>
        Order deny,allow
        Allow from all

Another random tip:

sudo doesn't bring the virtualenv with it! You have to su first, and then enter the virtualenv, and then do python bla bla

edit flag offensive delete link more


Thanks for sharing! This is the only solution that's working for me.

Vlad gravatar imageVlad ( 2012-04-15 13:23:10 -0500 )edit

answered 2011-05-30 02:33:52 -0500

DominiCattus gravatar image

updated 2011-05-30 17:40:10 -0500

I've created wiki page about it, askbot with virtualenv, uwsgi, nginx, everything on single IP with uwsgi and nginx as virtualhosts. Please feel free to add and correct :)

edit flag offensive delete link more


Thanks a lot!
Evgeny gravatar imageEvgeny ( 2011-05-30 06:34:47 -0500 )edit
The problem is you are using nginx, uwsgi while I am using Apache + modwsgi
DealsVistaCom gravatar imageDealsVistaCom ( 2011-05-30 10:53:08 -0500 )edit
Actually, you can contribute your Apache configs to this wiki article, so there will be various implementations.
DominiCattus gravatar imageDominiCattus ( 2011-05-30 17:39:22 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2011-05-30 01:52:57 -0500

Seen: 1,104 times

Last updated: May 30 '11