質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

Q&A

解決済

3回答

3276閲覧

nginx+php-fpm+サブドメインでWordPressを運用したい

sy_guji

総合スコア7

nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

0グッド

0クリップ

投稿2015/06/03 05:48

編集2015/06/06 03:38

以前知恵袋の方で質問したのですが、
投票受付状態になってやりとりができなくなったので、
専門性の高いこちらにて初めて質問させていただきます。
現在の状態、やりたいことはこちらに書いているのですが、
(http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q10145684720)
簡単に説明させていただくと、

・今www.immigrants.jpでWordPressを運用している
・サブドメイン(yushi.immigrants.jp)でもWordPressを運用したい
・サブドメイン(yushi.immigrants.jp)にWordPressを設置してアクセスすると、
ファイルの保存ダイアログが表示されたり、Not Foundになったり、真っ白なページしかでない。
・www.immigrants.jpは正常に動作している。

・WordPressのファイルは「/var/www/html/サブドメイン名」に置いている。
・設定は主にネットからググってコピペして自分用に一部変更

知恵袋やネットでの対策法を散々やりましたが、全然治りませんでした。
どうすればよいのでしょうか。
よろしくお願いします。

サブドメイン設定

lang

1server { 2listen 80; 3 server_name yushi.immigrants.jp; 4 access_log /var/log/nginx/yushi.access.log; 5 location / { 6 root /var/www/html/yushi; 7 index index.php; 8 } 9#location / { 10 # try_files $uri @wordpress; 11 # fastcgi_index index.php; 12 # fastcgi_split_path_info ^(.+\.php)(.*)$; 13 # fastcgi_pass unix:/var/run/php5-fpm.sock; 14 # fastcgi_param SCRIPT_FILENAME /var/www/html/yushi/$fastcgi_script_name; 15 # include fastcgi_params; 16 #} 17 18 #location @wordpress { 19 # fastcgi_index index.php; 20 # fastcgi_split_path_info ^(.+\.php)(.*)$; 21 # fastcgi_pass unix:/var/run/php5-fpm.sock; 22 #fastcgi_param SCRIPT_FILENAME /var/www/html/yushi/index.php; 23 #include fastcgi_params; 24 #} 25location ~ \.php$ { 26 # include snippets/fastcgi-php.conf; 27 # 28 # With php5-cgi alone: 29 # fastcgi_pass 127.0.0.1:9000; 30 # With php5-fpm: 31 fastcgi_pass unix:/var/run/php5-fpm.sock; 32 fastcgi_index index.php; 33 include fastcgi_params; 34 } 35}

編集後

lang

1server { 2listen 80; 3 server_name yushi.immigrants.jp; 4 root /var/www/html/yushi; 5 access_log /var/log/nginx/yushi.access.log; 6 7location / { 8 try_files $uri @wordpress; 9 fastcgi_index index.php; 10 fastcgi_split_path_info ^(.+\.php)(.*)$; 11 fastcgi_pass unix:/var/run/php5-fpm.sock; 12 fastcgi_param SCRIPT_FILENAME /var/www/html/yushi/$fastcgi_script_name; 13 include fastcgi_params; 14 } 15 16 location @wordpress { 17 fastcgi_index index.php; 18 fastcgi_split_path_info ^(.+\.php)(.*)$; 19 fastcgi_pass unix:/var/run/php5-fpm.sock; 20 fastcgi_param SCRIPT_FILENAME /var/www/html/yushi/index.php; 21 include fastcgi_params; 22 } 23 24 #lss the PHP scripts to FastCGI server listening on 127.0.0.1:9000 25 # 26 location ~ \.php$ { 27 # include snippets/fastcgi-php.conf; 28 # 29 # With php5-cgi alone: 30 # fastcgi_pass 127.0.0.1:9000; 31 # With php5-fpm: 32 fastcgi_pass unix:/var/run/php5-fpm.sock; 33 fastcgi_index index.php; 34 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 35 include fastcgi_params; 36 } 37}

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答3

0

ベストアンサー

www.immigrants.jp の設定と、ほとんど同じ設定にすれば動くはずです。
www.immigrants.jp の設定はどうなっていますか?
また、ここは異なる場ですから、そこまで長い内容でもないので、最初から全て説明しなおすべきだと思います。

root /var/www/html/yushi; は、location / {} の外に書いておいた方が良いでしょう。
try_files $uri @wordpress; 等のコメントアウトは全て戻して、server_name, access_log, root , fastcgi_param SCRIPT_FILENAME の設定以外は、同じ設定にそろえた方が良いでしょう。

切り分けについては、YukiMiyatake 様の回答を参考にされて下さい。

投稿2015/06/03 16:13

編集2015/06/04 03:17
takotakot

総合スコア1111

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

sy_guji

2015/06/04 02:56

そうですね、以後気をつけます。 こちら、www.immigrants.jpの設定ですが、 デフォルト設定にWordPress用のrewrite設定を足しただけです。 ## # You should look at the following URL's in order to grasp a solid understanding # of Nginx configuration files in order to fully unleash the power of Nginx. # http://wiki.nginx.org/Pitfalls # http://wiki.nginx.org/QuickStart # http://wiki.nginx.org/Configuration # # Generally, you will want to move this file somewhere, and start with a clean # file but keep this around for reference. Or just disable in sites-enabled. # # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. ## # Default server configuration # server { listen 80 default_server; listen [::]:80 default_server; # SSL configuration # # listen 443 ssl default_server; # listen [::]:443 ssl default_server; # # Self signed certs generated by the ssl-cert package # Don't use them in a production server! # # include snippets/snakeoil.conf; root /var/www/html; # Add index.php to the list if you are using PHP index index.php index.html index.htm index.nginx-debian.html; server_name www.immigrants.jp; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. #try_files $uri $uri/ =404; #try_files $uri $uri @wordpress; #rewrite /wpadmin/ /wpadmin/index.php permanent; } access_log off; log_not_found off; expires max; } location ~ \.php$ { try_files $uri @wordpress; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name; include fastcgi_params; } location @wordpress { fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_param SCRIPT_FILENAME /var/www/html/index.php; include fastcgi_params; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { # include snippets/fastcgi-php.conf; # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } # Virtual Host configuration for example.com # # You can move that to a different file under sites-available/ and symlink that # to sites-enabled/ to enable it. # server { listen 80; listen [::]:80; server_name file2.immigrants.jp; root /var/www/html/file2/; index index.html; location / { #try_files $uri $uri/ =404; limit_rate 5m; } location /somedir { autoindex on; } }
takotakot

2015/06/04 03:10

ありがとうございます。 設定を書く場合は、コメントではなく、自分の質問を編集・追記した方が、見やすいと思います。申し上げておくべきでした。今から、私の回答を追記します。
sy_guji

2015/06/06 03:32

了解しました。早速やってみたのですが相変わらず真っ白のままでした。 編集した内容を追記しておきます。 気になるのがnginx起動時に以下のエラーを吐いているのですが関係有るのでしょうか。 2015/06/06 12:29:20 [emerg] 27545#0: io_setup() failed (11: Resource temporarily unavailable) 2015/06/06 12:29:20 [emerg] 27544#0: io_setup() failed (11: Resource temporarily unavailable) 2015/06/06 12:29:20 [emerg] 27543#0: io_setup() failed (11: Resource temporarily unavailable) これでもwww.immigrants.jpの動作には問題は出ていません。
takotakot

2015/06/08 05:16

「www.immigrants.jpの動作には問題は出ていません」 ということであれば、関係ないと思います。気になるならば、新環境の conf ファイルを全く読まないようにして、同様のエラーが出るかチェックします。
guest

0

サーバー自体の調子も悪くなってきたので一度初期化し、
再度設定をしてみたところ、すんなりサブドメインでPHPを動作させることが出来ました。
何にひっかかっていたのか未だによく分かりません・・・

投稿2015/06/15 16:19

sy_guji

総合スコア7

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

問題の切り分けです。

yushi.immigrants.jpに
・pingやtracerouteは届きますか?
・静的なHTMLを置いた場合は正常に表示されますか?
・簡単なPHPは動作しますか?
・ブラウザキャッシュも消したりしてますか?
・DNSのサブドメインは設定してますか?
・DNSは設定してから反映されるまでに時間がかかる事がありますが十分な時間がたっていますか?

とりあえず そのあたりの回答があると、問題が切り出せると思います

投稿2015/06/04 03:01

YukiMiyatake

総合スコア144

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

sy_guji

2015/06/06 03:00

>・pingやtracerouteは届きますか? 届きます。 >・静的なHTMLを置いた場合は正常に表示されますか? 表示されます。 >・簡単なPHPは動作しますか? 試したところ、スクリプトの内容問わずCGI・PHPが動作しないです。 >・ブラウザキャッシュも消したりしてますか? 何度かしていますが解決していません。 >・DNSのサブドメインは設定してますか? >・DNSは設定してから反映されるまでに時間がかかる事がありますが十分な時間がたっていますか? 2ヶ月以上前から設定しています。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問