import os
import sys
sys.path.append('/home/neil')
sys.path.append('/home/neil/osqa-server')
# 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-server.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler() 4. 移除默认的Apache配置(可选)
官网说这个服务器只用于osqa,因此可以移除Apache的默认配置。
# 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
ServerAdmin forum@example.com
#osqa网站文件所在的目录
DocumentRoot /home/neil/osqa-server
#自定义
ServerName osqa.localhost
#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/ "/home/neil/osqa-server/forum/skins/"
Order allow,deny
Allow from all
Alias /upfiles/ "/home/neil/osqa-server/forum/upfiles/"
Order deny,allow
Allow from all
#this is your wsgi script described in the prev section
WSGIScriptAlias / /home/osqa/osqa-server/osqa.wsgi
CustomLog ${APACHE_LOG_DIR}/osqa.access.log common
ErrorLog ${APACHE_LOG_DIR}/osqa.error.log
CREATE USER 'osqa'@'localhost' IDENTIFIED BY 'your_osqa_password';
创建数据库
CREATE DATABASE osqa DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;
GRANT ALL ON osqa.* to 'osqa'@'localhost'; 7. 安装Python
linux默认是安装了python的,如果没有安装可以输入如下命令
接下来还有一步,不是很了解,原文如下。
With that command you have successfully defined the schema. With South installed, you also have the ability to migrate between databases--a useful feature as OSQA is updated. However, as this is a fresh install, you will need to convince South that the schema is already up to date by "faking" a migration. You can do that with the following command:
sudo python manage.py migrate forum --fake
10. 保证Apache被允许访问OSQA文件
这条命令表示osqa-server文件夹下的所有文件被neil用户和Apache group (www-data)拥有