2

我打算使用 osqa 问答脚本启动一个问答网站。我想在 Apache 服务器上安装 osqa。请告诉我在 Apache 服务器上安装 osqa 的简单但详细的步骤。

4

4 回答 4

3

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

于 2013-08-30T01:40:09.533 回答
3

第一步:安装相关的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

(一世)。创造osqa.wsgi

用于cp osqa.wsgi.dist osqa.wsgi复制和修改sys.path.append。will的最终内容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()

(二)。创造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

第五步:修改hosts

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

xx.xx.xx.xx example.com

参考:

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

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

于 2015-06-26T11:53:22.800 回答
1

嗨,我已经使用http://wiki.osqa.net/display/docs/Ubuntu+with+Apache+and+MySQL上的指南在新机器上完成了此操作,但针对新的 Apache 2.4.7 进行了修改,并降级了适当的版本django 和 Markdown 的

Ubuntu 14.04 阿帕奇 2.4.7

AWS 中的清洁机器:

sudo apt-get 更新

sudo apt-get install apache2 libapache2-mod-wsgi

sudo apt-get 安装颠覆

APACHE 2.4 表现不同 - 最好在 /var/www 中安装

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

须藤 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

须藤 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

须藤 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 迁移论坛 --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 服务 apache2 重启

于 2015-04-30T16:28:04.177 回答
0

首先你需要让 Django 运行

然后检查其他要求

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

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

于 2013-08-19T01:10:14.540 回答