laravel - Nginx 重写到不同的站点给出“未找到输入文件”
问题描述
我已经阅读了其他帖子,但我无法理解。我在一个目录中有一个 Laravel 应用程序 (listingnaples.test),在另一个目录中有一个 Wordpress (blog.listingnaples.test) 来分开存放。
http://blog.listingnaples.test有效。
http://listingnaples.test/blog/应该重定向但给出“未指定输入文件”错误。
希望答案无关紧要,但这是 Laravel 中用于本地开发的 Homestead 盒子。这是服务器块:
block="server {
listen ${3:-80};
listen ${4:-443} ssl http2;
server_name .$1;
root \"$2\";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files \$uri \$uri/ /index.php?\$query_string;
$headersTXT
}
$configureZray
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/$1-error.log error;
sendfile off;
client_max_body_size 100m;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php$5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
$paramsTXT
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
location ~ /\.ht {
deny all;
}
location /blog/ {
access_log off;
proxy_pass http://blog.listingnaples.test;
}
ssl_certificate /etc/nginx/ssl/$1.crt;
ssl_certificate_key /etc/nginx/ssl/$1.key;
}
编辑:错误日志
错误日志中有以下几行:
2018/11/26 21:09:28 [emerg] 600#600: location "/blog/" is outside location "\.php$" in /etc/nginx/sites-enabled/blog.listingnaples.test:50
2018/11/26 21:27:01 [emerg] 7798#7798: invalid URL prefix in /etc/nginx/sites-enabled/listingnaples.test:49
2018/11/26 21:51:48 [emerg] 23588#23588: invalid URL prefix in /etc/nginx/sites-enabled/listingnaples.test:49
编辑2:那不是代码所在的地方
2018/11/26 21:25:41 [error] 5392#5392: *11 FastCGI sent in stderr: "Unable to open primary script: /home/vagrant/code/ln/public/blog/index.php (No such file or directory)" while reading response header from upstream, client: 192.168.10.1, server: listingnaples.test, request: "GET /blog/index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.2-fpm.sock:", host: "listingnaples.test"
该博客不在 /home/vagrant/code/ln/public/blog/index.php 中。它在 /home/vagrant/code/blog.listingnaples.com/index.php
因此,我想尝试重定向但完全重定向到错误的目录。
通常一个提示会帮助我,但现在我更困惑了。