How to install osqa in simple steps

3.7k Views Asked by At

I am planning to start a question answer website using osqa question answer script. I want to install osqa on Apache server. Please tell me simple but detailed steps to install osqa on Apache server.

4

There are 4 best solutions below

0
On

Step 1: install related python modules

sudo apt-get install python-setuptools  #which contains easy_install 
sudo apt-get install python-pip

sudo apt-get install python-django
sudo apt-get install python-mysqldb  
sudo apt-get install libapache2-mod-wsgi  #mod-wsgi, sudo a2enmod mod-wsgi
sudo easy_install ElementTree html5lib python-openid

sudo pip install Markdown==2.4.1  #NOTE: the higher version is incompatible with osqa
sudo pip install south

Step 2: Create a database for OSQA

# (i).download the source code of OSQA
git clone https://github.com/OSQA/osqa.git

# (ii).create a database, named osqa
mysql -u root -p   #you are required to type password
create database osqa DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;


# (iii).create tables for OSQA
/var/www/osqa$ python manage.py syncdb
......
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): no
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)

Step 3: Configure OSQA

(i). Create osqa.wsgi

Use cp osqa.wsgi.dist osqa.wsgi to make a copy and modify sys.path.append. The final content of osqa.wsgi will be

import os
import sys
sys.path.append('/var/www')
sys.path.append('/var/www/osqa')
# The first part of this module name should be identical to the directory name
# of the OSQA source.  For instance, if the full path to OSQA is
# /home/osqa/osqa-server, then the DJANGO_SETTINGS_MODULE should have a value
# of 'osqa-server.settings'.
os.environ['DJANGO_SETTINGS_MODULE'] = 'osqa.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

(ii). Create settings_local.py

Use cp settings_local.py.dist settings_local.py to make a copy and make some change. The following code shows what codes should be changed.

DATABASES = { 
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'osqa',
        'USER': 'root',
        'PASSWORD': '**********',
        'HOST': '',
        'PORT': '',
        'CONN_MAX_AGE': 600,
    }
}

APP_URL = 'http://www.example.com

ALLOWED_HOSTS = ('example.com',)

Step 4: Configure apache

Create a configure file for OSQA (say osqa.conf). Here is the content:

# Must be readable and writable by apache
WSGISocketPrefix ${APACHE_RUN_DIR}

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/osqa
    ServerName example.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/ "/var/www/osqa/forum/skins/"
    <Directory "/var/www/osqa/forum/skins">
        Require all granted
    </Directory>

    Alias /upfiles/ "/var/www/osqa/forum/upfiles/"
    <Directory "/var/www/osqa/forum/upfiles">
        Require all granted 
    </Directory>

    #this is your wsgi script described in the prev section
    WSGIScriptAlias / /var/www/osqa/osqa.wsgi

    CustomLog ${APACHE_LOG_DIR}/osqa.access.log common
    ErrorLog ${APACHE_LOG_DIR}/osqa.error.log
</VirtualHost>

Make the configure take effect:

sudo a2ensite osqa.conf
sudo service apache2 restart

Step 5: Modify hosts

Append the following to /etc/hosts

xx.xx.xx.xx example.com

References:

http://sparkandshine.net/install-osqa-on-aws-ec2-ubuntu-apache-mysql/

PS: why does not the highligter syntax work?

2
On

If you want something simple you could use bitnami stack http://bitnami.com/stack/osqa

2
On

First you need to get Django going

then check the other requirements

http://meta.osqa.net/questions/11025/server-requirements-to-run-osqa

I'll tell you to ask this question at that forum, but it looks pretty much dead already

1
On

Hi I have done this on a new machine using the guide at http://wiki.osqa.net/display/docs/Ubuntu+with+Apache+and+MySQL but amending it for new Apache 2.4.7 and also downgrading appropriate versions of django and Markdown

Ubuntu 14.04 Apache 2.4.7

Clean machine in AWS:

sudo apt-get update

sudo apt-get install apache2 libapache2-mod-wsgi

sudo apt-get install subversion

APACHE 2.4 behaves Differently - best to insatll in /var/www

sudo svn co http://svn.osqa.net/svnroot/osqa/trunk/ /var/www/osqa

sudo vi /var/www/osqa/osqa.wsgi

import os
import sys
sys.path.append('/var/www')
sys.path.append('/var/www/osqa')
# The first part of this module name should be identical to the directory name
# of the OSQA source.  For instance, if the full path to OSQA is
# /home/osqa/osqa-server, then the DJANGO_SETTINGS_MODULE should have a value
# of 'osqa-server.settings'.
os.environ['DJANGO_SETTINGS_MODULE'] = 'osqa.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

sudo rm /etc/apache2/sites-enabled/000-default.conf

sudo vi /etc/apache2/sites-available/osqa.conf

# 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 [email protected]
    DocumentRoot /var/www/osqa
    ServerName example.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/ "/var/www/osqa/forum/skins/"
        <Directory "/var/www/osqa/forum/skins">
            Require all granted
        </Directory>
    Alias /upfiles/ "/var/www/osqa/forum/upfiles/"
    <Directory "/var/www/osqa/forum/upfiles">
        Require all granted 
    </Directory>

    #this is your wsgi script described in the prev section
    WSGIScriptAlias / /var/www/osqa/osqa.wsgi

    CustomLog ${APACHE_LOG_DIR}/osqa.access.log common
    ErrorLog ${APACHE_LOG_DIR}/osqa.error.log
</VirtualHost>

sudo ln -s /etc/apache2/sites-available/osqa.conf /etc/apache2/sites-enabled/osqa.conf

sudo apt-get install mysql-client
sudo apt-get install python-setuptools
sudo apt-get install python-pip

sudo easy_install South django-debug-toolbar markdown \ html5lib python-openid

sudo pip install Django==1.3

sudo pip install Markdown==2.4.1

sudo cp /var/www/osqa/settings_local.py.dist /var/www/osqa/settings_local.py

sudo vi /var/www/osqa/settings_local.py

DO your database stuff - I already had one on RDS but you can make your own.

DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': 'osqa',
            'USER': '',
            'PASSWORD': '',
            'HOST': '',
            'PORT': '3306',
        }
    }

I didn't do this step but you probably need to if building a new db sudo python manage.py syncdb --all

sudo python manage.py migrate forum --fake

sudo useradd osqa

sudo chown -R osqa:www-data /var/www/osqa

sudo chmod -R g+w /var/www/osqa/forum/upfiles

sudo chmod -R g+w /var/www/osqa/log

sudo service apache2 restart