今回は、askbotに関して紹介します(`・ω・´)
askbotに関しては、情報が少なくpythonということもあり、少し苦労しました(´д`ι)
askbotとは、Q&Aのシステムです。簡単に言うと、yahoo知恵袋的な質問サイトのOSSです。早速インストールをしてみましょう(〃´∀`〃)ノ
まず、必要なパッケージをインストールします。
# yum install python-devel mod_wsgi mariadb-devel mariadb-server httpd mod_ssl |
pip(Pythonにおけるパッケージ管理システム)のインストールをします。
# yum install python-setuptools # easy_install pip |
先ほどインストールしたpipを使い、askbotのインストールをします。
# pip install askbot # pip install mysql-python # pip install django-robots==1.0 |
askbotは簡単に入りましたでしょうか?ここから設定に移ります!
まず、askbotで使うデータベースとユーザを作ります。初期セットアップコマンドがあり対話形式に進めていきます!rootパスワードを設定するところ以外はそのままEnterで大丈夫です。
# systemctl start mariadb # mysql_secure_installation # mysql -u root -p MariaDB [(none)]> create database askbot DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci; MariaDB [(none)]> grant all privileges on askbot.* to askbot@localhost identified by 'askbot'; |
次は、askbotの設定に入ります。askbotのプロジェクト名や、どのデータベースを使うのか情報の入力を求められます。mysqlを選択し、先ほど作成したデータベースを指定します。
# cd /var/www/html # askbot-setup ~ Deploying Askbot - Django Q&A forum application Problems installing? -> please email admin@askbot.org To CANCEL - hit Ctr-C at any time Enter directory path (absolute or relative) to deploy askbot. To choose current directory - enter "." > askbot-test Adding new directories: /var/www/html <-/askbot-test Accept? type yes/no: yes Please select database engine: 1 - for postgresql, 2 - for sqlite, 3 - for mysql, 4 - oracle type 1/2/3/4: 3 Please enter database name (required) > askbot Please enter database user (required) > askbot Please enter database password (required) > askbot Copying files: * __init__.py * manage.py * urls.py * django.wsgi Creating settings file settings file created copying directories: * doc * cron * upfiles Done. Please find further instructions at http://askbot.org/doc/ |
askbotの初期設定を行います。まず、プロジェクトのディレクトリに移動し、設定を書き換えます。使われなくなった設定?もあるようで、askbotを起動したときにエラーログが表示されるので、事前にコメントアウトしておきます。
# cd askbot-test/
# vi settings.py
~
DEBUG = True
ADMINS = (
('Your Name', 'your_email@domain.com'),
)
TIME_ZONE = 'America/Chicago'
CACHE_PREFIX = 'askbot' #make this unique
~
↓
~
DEBUG = False
ADMINS = (
('Your Name', '[メールアドレス]'),
)
TIME_ZONE = 'Asia/Tokyo'
#CACHE_PREFIX = 'askbot' #make this unique
~
|
askbotのを初期化をします(*^ワ^*)
# python manage.py collectstatic # python manage.py syncdb |
askbotのキャッシュテーブルを作成します。初期は、メモリにキャッシュするようになっていますが、それだとログにエラーが出るため、データベース上に作成しておきます。
# python manage.py createcachetable cache_table
# vi settings.py
~
CACHE_BACKEND = 'locmem://'
~
↓
~
CACHE_BACKEND = 'db:///cache_table'
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
'LOCATION': 'cache_table',
}
}
~
|
askbotの権限を変更します。
cd /var/www/html chown -R root:apache askbot-test chmod -R g+w askbot-test/askbot/upfiles chmod -R g+w askbot-test/log |
SELinuxが動作している場合、設定をする必要がありますが、SELinuxに関しは今回は一旦OFFにしておきます。さぼってすいません(ノД`)・゜・。
# setenforce 0 |
apacheの設定については、askbotを実行できるように設定を追加します。後は一応簡単なセキュリティ対策くらいはしましょうか (´´・Д・`)ノ
# vi /etc/httpd/conf.d/askbot.conf
~
WSGISocketPrefix /var/run/wsgi
<Directory "/var/www/html/askbot-test">
Order deny,allow
Allow from all
</Directory>
<VirtualHost *:80>
ServerAdmin root@askbot-test.co.jp
DocumentRoot /var/www/html/askbot-test
ServerName askbot-test.co.jp
Alias /m/ /var/www/html/askbot-test/static/
Alias /upfiles/ /var/www/html/askbot-test/askbot/upfiles/
<DirectoryMatch "/var/www/html/askbot-test/askbot/skins/([^/]+)/media">
Order deny,allow
Allow from all
</DirectoryMatch>
<Directory "/var/www/html/askbot-test/askbot/upfiles">
Order deny,allow
Allow from all
</Directory>
#must be a distinct name within your apache configuration
WSGIDaemonProcess askbot2
WSGIProcessGroup askbot2
WSGIScriptAlias / /var/www/html/askbot-test/django.wsgi
#make all admin stuff except media go through secure connection
<LocationMatch "/admin(?!/media)">
RewriteEngine on
RewriteRule /admin(.*)$ https://askbot-test.co.jp/admin$1 [L,R=301]
</LocationMatch>
CustomLog /var/log/httpd/access_log common
ErrorLog /var/log/httpd/error_log
</VirtualHost>
#again, replace the IP address
<VirtualHost *:443>
ServerAdmin root@askbot-test.co.jp
DocumentRoot /var/www/html/askbot-test
ServerName askbot-test.co.jp
<LocationMatch "^(?!/admin)">
RewriteEngine on
RewriteRule django.wsgi(.*)$ http://askbot-test.co.jp$1 [L,R=301]
</LocationMatch>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
Alias /admin/media/ /usr/local/lib/python2.6/site-packages/django/contrib/admin/media/
WSGIScriptAlias / /var/www/html/askbot-test/django.wsgi
CustomLog /var/log/httpd/access_log common
ErrorLog /var/log/httpd/error_log
</VirtualHost>
~
|
# vi /etc/httpd/conf/httpd.conf ~ ServerTokens Prod ServerSignature Off TraceEnable off ~ # systemctl start httpd |
ここまでこれば、以下のような画面が表示されると思います\(^ ^)/
http://askbot-test.co.jp/

ただ、askbotの設定をwebインタフェースから変更しようとしても、以下のようにエラー表示が出てしまい、変更できませんでした。

djangoの設定を変えておかないといけないようで、以下のように設定する必要があります。
# python manage.py shell ~ >>> from django.contrib.sites.models import Site >>> site = Site() >>> site.domain = 'askbot-test.co.jp' >>> site.name = 'askbot-test.co.jp' >>> site.save() >>> quit() |
次に、LDAPの連携です。以下の設定を入れて、apacheを再起動するのみでOkです。(*・ω・)ノ
# cd askbot-test/
# vi settings.py
~
import ldap
LIVESETTINGS_OPTIONS = {
1: {
'DB' : True,
'SETTINGS': {
'LDAP_SETTINGS': {
'USE_LDAP_FOR_PASSWORD_LOGIN': True,
'LDAP_URL': 'ldap://[ldapサーバのIPアドレス]:389',
'LDAP_LOGIN_DN': '[ldapのDN]',
'LDAP_PASSWORD': '[パスワード]',
'LDAP_BASE_DN': '[ldapのBASEDN]',
}
}
}
}
~
|
こんな感じでできました(ノ´д`ノ。・ゎーぃ・。\´д`\)
ただ、いろいろと間違っている可能性は多いにあるので、何かあればご指摘ください!
ちなみに、公式サイトはここです。
https://askbot.com/