First time here? Check out the FAQ!
0

How to setup AskBot with virtualenv?
 

Has anyone try virtualenv with AskBot?

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
DealsVistaCom's avatar
137
DealsVistaCom
asked 13 years ago

Comments

see more comments

2 Answers

1

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 howtox.com

First,

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

Then, I followed the instruction here:

http://askbot.org/doc/install.html

pip install askbot

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

create database howtox DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;

Then,

startforum forum
python manage.py syncdb
python manage.py migrate askbot
python manage.py 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
site.addsitedir('/home/deals/howtox/virtpy/lib/python2.6/site-packages')

# Avoid error msg
import os
os.environ['PYTHON_EGG_CACHE']='/var/www/howtox.com/egg-cache'

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

sys.path.append(parent_directory)
sys.path.append(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.remove(item)
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/howtox.com
-- egg-cache

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

<VirtualHost 68.68.99.163:80>
    ServerName howtox.com
    ServerAlias www.howtox.com
    ServerAdmin help@howtox.com

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

    #Log
    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
    </Directory>
</VirtualHost>

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 manage.py bla bla

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
answered 13 years ago
This post is a wiki. Anyone with karma >100 is welcome to improve it.
link

Comments

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

Vlad's avatar Vlad (12 years ago)
see more comments
1

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 :)

http://askbot.org/wiki/index.php/Askbot_on_VirtualHost

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
DominiCattus's avatar
105
DominiCattus
updated 13 years ago, answered 13 years ago
link

Comments

Thanks a lot!
Evgeny's avatar Evgeny (13 years ago)
The problem is you are using nginx, uwsgi while I am using Apache + modwsgi
DealsVistaCom's avatar DealsVistaCom (13 years ago)
Actually, you can contribute your Apache configs to this wiki article, so there will be various implementations.
DominiCattus's avatar DominiCattus (13 years ago)
see more comments