如何以简单的步骤安装osqa

时间:2013-07-27 14:31:22

标签: osqa

我计划使用osqa问题答案脚本开始问答网站。我想在Apache服务器上安装osqa。请告诉我在Apache服务器上安装osqa的简单但详细的步骤。

4 个答案:

答案 0 :(得分:3)

如果你想要简单的东西,可以使用bitnami stack http://bitnami.com/stack/osqa

答案 1 :(得分:2)

第1步:安装相关的python模块

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

第2步:为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)

第3步:配置OSQA

(i)中。创建osqa.wsgi

使用cp osqa.wsgi.dist osqa.wsgi制作副本并修改sys.path.appendosqa.wsgi的最终内容将是。{1}}

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)中。创建settings_local.py

使用cp settings_local.py.dist settings_local.py制作副本并进行更改。以下代码显示了应更改的代码。

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',)

第4步:配置apache

为OSQA创建配置文件(例如osqa.conf)。以下是内容:

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

<VirtualHost *:80>
    ServerAdmin admin@example.com
    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 a2ensite osqa.conf
sudo service apache2 restart

第5步:修改hosts

将以下内容附加到/etc/hosts

xx.xx.xx.xx example.com

参考文献:

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

PS:为什么highligter语法不起作用?

答案 2 :(得分:0)

首先你需要让Django继续

然后检查其他要求

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

我会告诉你在那个论坛上提出这个问题,但它看起来已经死了

答案 3 :(得分:0)

您好我使用http://wiki.osqa.net/display/docs/Ubuntu+with+Apache+and+MySQL指南在新机器上完成了此操作,但修改了新的Apache 2.4.7以及降级django和Markdown的相应版本

Ubuntu 14.04 Apache 2.4.7

在AWS中清理机器:

sudo apt-get update

sudo apt-get install apache2 libapache2-mod-wsgi

sudo apt-get install subversion

APACHE 2.4表现不同 - 最好在/ 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 forum@example.com
    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南方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

做你的数据库 - 我已经在RDS上有一个,但你可以自己制作。

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

我没有这样做,但你可能需要建立一个新的数据库 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