7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【3度目の正直】 Stack Overflowのクローン、 Question2Answer を CentOSにインストール

Posted at

Rails の shapado, Django の Askbot のインストールに失敗して心が半分折れてましたが、やっとStack Overflowのクローンのインストールに成功したので記録として残します。

インストール方法

ここに書いてる。
http://www.question2answer.org/install.php

Nginx の設定

ただ上の設定だとApacheでNginxに対策がちゃんとできてないのでこんなエラーになる。

2013/09/11 05:16:44 [error] 32579#0: *327 FastCGI sent in stderr: "PHP message: PHP Question2Answer MySQL query error 1146: Table 'xxxxxx.qa_options' doesn't exist - Query: (SELECT 'options' AS selectkey, title, content FROM qa_options) UNION ALL (SELECT 'time', 'db_time', UNIX_TIMESTAMP(NOW()))" while reading response header from upstream, client: 180.13.120.139, server: myserver, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/www.sock:", host: "myserver"

/etc/nginx/site-available/example.comの抜粋
  location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php-fpm/www.sock;
    # fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include /etc/nginx/fastcgi_params;
  }

if (!-e $request_filename) {
                rewrite ^(.+)$ /index.php?qa-rewrite=$1 last;
                break;
        }

ここで Wordpressを動かすのには必要なかった fastcgi_split_path_info が抜けてたのが問題の原因だったらしい。

下の設定は /123/hoge みたいにきれいなURLするのに必要な設定。

日本語化

http://www.question2answer.org/addons.php
から日本語のファイルを落としてきて展開、出てきた ja フォルダを qa-lang の配下にいれる。
あとは設定画面で言語ファイルのチェックをすれば日本語が選択できるようになる。

マルチバイトに対応

The installed version of PHP was compiled without multibyte string support. Searching will be less effective for non-Roman characters.

日本語のメッセージはコピペし忘れてたけど、とりあえずマルチバイトサポートなしでコンパイルされてるので日本語の検索が遅いらしい。てっきりPHP本体のコンパイルしなおしでまた1時間ぐらい待たされるのかと思ったら

$ sudo yum install php-mbstring
$ sudo service php-fpm restart

だけだったのでさくっとすんだ。

参考

fastcgi_split_path_info ^(.+.php)(/.+)$;
http://www.howtoforge.com/running-question2answer-on-nginx-lemp-on-debian-squeeze-ubuntu-12.10

Question2Answer mit nginx- Rewrite Rules für den Webserver « Leben des wolf-u.li
http://wolf-u.li/4361/question2answer-mit-nginx-rewrite-rules-fuer-den-webserver/

How do I enable multibyte string processing in PHP on CentOS, RedHat, etc., Linux?
http://www.colickyclown.com/a/loader.php/sites/ColickyClown/faq/00025/

7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?