![同じドメイン内の Nginx と fastcgi を使用した複数の WordPress インスタンス](https://rvso.com/image/515679/%E5%90%8C%E3%81%98%E3%83%89%E3%83%A1%E3%82%A4%E3%83%B3%E5%86%85%E3%81%AE%20Nginx%20%E3%81%A8%20fastcgi%20%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%9F%E8%A4%87%E6%95%B0%E3%81%AE%20WordPress%20%E3%82%A4%E3%83%B3%E3%82%B9%E3%82%BF%E3%83%B3%E3%82%B9.png)
私のサイトは Apache 上で実行されています。/tr/ と /eng/ のパスに wordpress のインスタンスが 2 つ存在します。セットアップを nginx に移行したいのですが、うまく動作させることができません。
私のセットアップは、nging 0.7.66、php 5.3.2、php-fpm で構成されています。/tr/ と /eng/ は、それぞれ /home/istci/webapps/wordpress_tr と /home/istci/webapps/wordpress の下にある 2 つの別々の wordpress インスタンスです。
以下は、tr の設定のみを含む nginx.conf のサーバー セクションですが、これも動作しませんでした。
server {
listen 80;
server_name www.example.com;
charset utf-8;
location ~ ^/$ {
rewrite ^(.+)$ http://www.example.com/tr/ permanent;
}
location ~ /tr/.*php$ {
fastcgi_pass unix:/home/istci/var/run/wptr.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/istci/webapps/wordpress_tr$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
}
location /tr/ {
root /home/istci/webapps/wordpress_tr/;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.+)$ /tr/index.php?q=$1 last;
break;
}
if (-f $request_filename) {
expires 30d;
break;
}
}
}
php-fpm は unix:/home/istci/var/run/wptr.sock をリッスンします。デバッグ モードで実行すると、アクティブなハンドラーが表示されません。つまり、nginx から unix ソケットへの接続は行われません。
nginx アクセスログ:
127.0.0.1 - - [09/Jun/2010:03:45:11 -0500] "GET /tr/ HTTP/1.0" 404 20 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.4) Gecko/20100527 Firefox/3.6.4"
nginx デバッグ ログ:
2010/06/09 03:38:53 [notice] 6922#0: built by gcc 4.1.2 20080704 (Red Hat 4.1.2-48)
2010/06/09 03:38:53 [notice] 6922#0: OS: Linux 2.6.18-164.9.1.el5PAE
2010/06/09 03:38:53 [notice] 6922#0: getrlimit(RLIMIT_NOFILE): 4096:4096
2010/06/09 03:38:53 [notice] 6923#0: start worker processes
2010/06/09 03:38:53 [notice] 6923#0: start worker process 6924
2010/06/09 03:38:53 [notice] 6923#0: start worker process 6925
2010/06/09 03:39:01 [notice] 6925#0: *1 "^(.+)$" matches "/tr/", client: 127.0.0.1, server: www.example.com, request: "GET /tr/ HTTP/1.0", host: "www.example.com"
2010/06/09 03:39:01 [notice] 6925#0: *1 rewritten data: "/tr/index.php", args: "q=/tr/", client: 127.0.0.1, server: www.example.com, request: "GET /tr/ HTTP/1.0", host: "www.example.com"
私の設定の何が問題なのか、何か手がかりはありますか? ありがとうございます。
答え1
について読むtry_files
location /tr {
try_files $uri $uri/ /tr/index.php;
}
location /eng {
try_files $uri $uri/ /eng/index.php;
}
これを追加。