質問編集履歴

2

追記

2025/05/29 10:13

投稿

BreadMan
BreadMan

スコア4

test CHANGED
File without changes
test CHANGED
@@ -189,6 +189,8 @@
189
189
  ###追記
190
190
  回答を元にloacationの中にrootを追加したが、動作に変更はなかった。
191
191
  (ダミーページが返ってきた)
192
- 補足にconfファイルの全文を記載した
192
+ 補足にconfファイルの全文を記載した
193
193
 
194
+ 質問者はphpに関して知識はない。
195
+ (confファイルも元々作成していた別のwordpressプロビジョンからコピペし、意味も分からず改造したもの)
194
196
 

1

追記

2025/05/29 10:11

投稿

BreadMan
BreadMan

スコア4

test CHANGED
File without changes
test CHANGED
@@ -30,7 +30,7 @@
30
30
 
31
31
  試したこと1
32
32
  ↑の質問と回答を踏まえ、
33
-
33
+ ```php
34
34
  location /(サブディレクトリ名)/ {
35
35
  alias /home/kusanagi/(プロビジョン名)/DocumentRoot/;
36
36
  index index.php;
@@ -40,6 +40,8 @@
40
40
  include conf.d/fastcgi.inc;
41
41
  }
42
42
  }
43
+ ```
44
+
43
45
  とした。
44
46
  404や403といったものは返ってこなくなったが、
45
47
  (サブドメイン)/(サブディレクトリ)/
@@ -49,19 +51,25 @@
49
51
  試したこと2
50
52
  include conf.d/fastcgi.inc;
51
53
  をincludeせずに中身をフルパス指定にして書き換えた
54
+ ```php
55
+
56
+ location ~ \.php$ {
52
- fastcgi_split_path_info ^(.+?\.php)(/.*)$;
57
+ fastcgi_split_path_info ^(.+?\.php)(/.*)$;
53
- if (!-f /home/kusanagi/(プロビジョン名)/DocumentRoot$fastcgi_script_name) {
58
+ if (!-f /home/kusanagi/(プロビジョン名)/DocumentRoot$fastcgi_script_name) {
54
59
  return 404;
55
60
  }
56
- fastcgi_pass (IP):(Port?);
61
+ fastcgi_pass (IP):(Port?);
57
- fastcgi_index index.php;
62
+ fastcgi_index index.php;
58
- fastcgi_param SCRIPT_FILENAME /home/kusanagi/(プロビジョン名)/DocumentRoot$fastcgi_script_name;
63
+ fastcgi_param SCRIPT_FILENAME /home/kusanagi/(プロビジョン名)/DocumentRoot$fastcgi_script_name;
59
- fastcgi_param HTTP_HOST $host;
64
+ fastcgi_param HTTP_HOST $host;
60
- include fastcgi_params;
65
+ include fastcgi_params;
61
- fastcgi_buffers 256 128k;
66
+ fastcgi_buffers 256 128k;
62
- fastcgi_buffer_size 128k;
67
+ fastcgi_buffer_size 128k;
63
- fastcgi_intercept_errors on;
68
+ fastcgi_intercept_errors on;
64
- fastcgi_read_timeout 120s;
69
+ fastcgi_read_timeout 120s;
70
+ }
71
+ ```
72
+
65
73
 
66
74
  が、動作に変わりはなかった
67
75
 
@@ -70,5 +78,117 @@
70
78
 
71
79
  ### 補足情報(FW/ツールのバージョンなど)
72
80
 
73
- 質問やコメントに応じて随時追記
74
81
 
82
+ メインドメインのconfファイル全文
83
+ ```php
84
+ server {
85
+ listen 80;
86
+ listen [::]:80;
87
+
88
+ server_name (メインドメイン) www.(メインドメイン);
89
+
90
+ set $do_not_cache 0; ## page cache
91
+ set $expire_days 90d;
92
+
93
+ access_log (略) main;
94
+ error_log (略) warn;
95
+
96
+
97
+ charset UTF-8;
98
+ client_max_body_size 600M;
99
+ root /home/(メインドメインHPのindex.htmlがあるファイルのパス);
100
+
101
+ include conf.d/505.inc;
102
+ include conf.d/favicon.inc;
103
+ include conf.d/acme.inc;
104
+ include conf.d/static.inc;
105
+
106
+ return 301 https://$host$request_uri;
107
+  }
108
+
109
+  server {
110
+ include conf.d/ssl_listen.inc;
111
+
112
+ server_name (メインドメイン) www.(メインドメイン);
113
+
114
+ set $do_not_cache 0; ## page cache
115
+ set $expire_days 90d;
116
+
117
+ ssl_certificate (略);
118
+ ssl_certificate_key (略);
119
+ ssl_password_file (略);
120
+
121
+ ssl_ct off;
122
+ ssl_ct_static_scts /etc/opt/kusanagi/nginx;
123
+
124
+ include conf.d/ssl.inc;
125
+ ssl_stapling off;
126
+ ssl_stapling_verify off;
127
+ resolver 8.8.4.4 8.8.8.8 valid=300s;
128
+ resolver_timeout 10s;
129
+
130
+ access_log (略) main;
131
+ error_log (略) warn;
132
+
133
+ charset UTF-8;
134
+ client_max_body_size 600M;
135
+ root /home/(メインドメインHPのindex.htmlがあるファイルのパス);
136
+
137
+ include conf.d/505.inc;
138
+ include conf.d/favicon.inc;
139
+ include conf.d/acme.inc;
140
+
141
+ location ~ [^/]\.cgi$ {
142
+ include conf.d/fcgi.inc;
143
+ }
144
+
145
+ location /(サブディレクトリ)/ {
146
+ alias /home/kusanagi/(プロビジョン名)/DocumentRoot/;
147
+ index index.php;
148
+ try_files $uri $uri/ /index.php?$args;
149
+ location ~ \.php$ {
150
+ rewrite ^/(サブディレクトリ)/(.*\.php)$ /$1 break;
151
+ root /home/kusanagi/(プロビジョン名)/DocumentRoot/;
152
+ fastcgi_split_path_info ^(.+?\.php)(/.*)$;
153
+ if (!-f $document_root$fastcgi_script_name) {
154
+ return 404;
155
+ }
156
+ fastcgi_pass (IP):(Port?);
157
+ fastcgi_index index.php;
158
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
159
+ fastcgi_param HTTP_HOST $host;
160
+ include fastcgi_params;
161
+ fastcgi_buffers 256 128k;
162
+ fastcgi_buffer_size 128k;
163
+ fastcgi_intercept_errors on;
164
+ fastcgi_read_timeout 120s;
165
+ }
166
+
167
+ }
168
+
169
+ location ~ [^/]\.(php|html)(/|$) {
170
+ include conf.d/ratelimit.inc;
171
+ include conf.d/fastcgi.inc;
172
+ if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
173
+ set $do_not_cache 1;
174
+ }
175
+
176
+ include conf.d/fastcgi_cache.inc;
177
+
178
+ add_header X-Signature KUSANAGI;
179
+
180
+ }
181
+
182
+ include conf.d/static.inc;
183
+ include conf.d/fcache_purge.inc;
184
+
185
+  }
186
+ ```
187
+  
188
+
189
+ ###追記
190
+ 回答を元にloacationの中にrootを追加したが、動作に変更はなかった。
191
+ (ダミーページが返ってきた)
192
+ 補足にconfファイルの全文を記載した
193
+
194
+