MAMPにはapacheもnginxも同梱されているのですが、apacheでfuelphpのpublic/welcome/indexにアクセスすると普通にOKなんですが、nginxに切り替えると404 Not Foundが返ってきます。
何が原因と考えられますでしょうか。
URLの打ち間違えとかははないです。
ローカルなので動きませんが一応パスです。
http://localhost/Dev/personal/web/model_fuelphp/public/welcome/index
↑apacheでは動きますが、nginxでは動きません。
ngineでやったことといえば、serverディレクティブでallindex onにしたぐらいです。
あと、
http://localhost/Dev/personal/web/model_fuelphp/public/
ここまではnginxでも読み込めて実際に読んでいるパスは
http://localhost/Dev/personal/web/model_fuelphp/public/welcome/index
のはずです。
nginxの設定なのか、fuelphpの設定なのか皆目つかずです。。。
ここから推測ですが多分、
serverソフト側で設定している「なにか」を「fuelphp」で受け取っていて、
apacheの場合だとfuelphpには「それ」があって、
nginxの場合だとfuelphpには「それ」がないからなのかなとか思ってます。
「それ」があるかどうかも「それ」が何なのかも分からないので、どう調べたらいいかも分からず、、、
一応nginxの設定ファイルです。
#load_module "modules/ngx_http_image_filter_module.so"; #load_module "modules/ngx_http_perl_module.so"; #load_module "modules/ngx_http_xslt_filter_module.so"; #load_module "modules/ngx_mail_module.so"; #load_module "modules/ngx_stream_module.so"; user root admin; worker_processes 2; events { worker_connections 1024; } http { include mime.types; default_type text/html; gzip on; gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon; sendfile on; server { listen 80 default_server; # MAMP DOCUMENT_ROOT !! Don't remove this line !! root "/Applications/MAMP/htdocs"; autoindex on; access_log /Applications/MAMP/logs/nginx_access.log; error_log /Applications/MAMP/logs/nginx_error.log; location / { index index.html index.php; } location ~* /MAMP[^-]*(.*)$ { root /Applications/MAMP/bin; index index.php; location ~ .php$ { try_files $uri =404; fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } location ~* /phpMyAdmin(.*)$ { root /Applications/MAMP/bin; index index.php; location ~ .php$ { try_files $uri =404; fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } location ~* /phpPgAdmin(.*)$ { root /Applications/MAMP/bin; index index.php; location ~ .php$ { try_files $uri =404; fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } location ~* /phpLiteAdmin(.*)$ { root /Applications/MAMP/bin; index index.php; location ~ .php$ { try_files $uri =404; fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } location ~* /adminer(.*)$ { root /Applications/MAMP/bin; index adminer.php; location ~ .php$ { try_files $uri =404; fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } location /icons { alias /Applications/MAMP/Library/icons; autoindex on; } location /favicon.ico { alias /Applications/MAMP/bin/favicon.ico; # log_not_found off; # access_log off; } location ~ .php$ { try_files $uri =404; fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /. { deny all; } # location ~* .(gif|jpg|png|pdf)$ { # expires 30d; # } # location = /robots.txt { # allow all; # log_not_found off; # access_log off; # } # location ~* .(txt|log)$ { # allow 127.0.0.1; # deny all; # } # location ~ ..*/.*.php$ { # return 403; # } location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; deny all; } } # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} }
追記:
var_dump($_SERVER)の時点でそれぞれの出力に違いがありますね、、、
nginxのエラーログには下記がでています。
ファイルをディレクトリもひらけないと、、、
うーん、apacheと何が違うのでしょう、、、
2018/02/09 19:47:49 [error] 40056#0: *1 open() "/Applications/MAMP/htdocs/Dev/personal/web/model_fuelphp/public/welcome/hello" failed (2: No such file or directory), client: 127.0.0.1, server: , request: "GET /Dev/personal/web/model_fuelphp/public/welcome/hello HTTP/1.1", host: "localhost"
追記:
これが参考になりそうな予感。
https://teratail.com/questions/47368
ちょっとづつ解決に近づいてきた予感。
あなたの回答
tips
プレビュー