我正在尝试使用基本的 master/catch-all vhost 配置来设置我的开发 nginx/PHP 服务器,以便我可以根据需要创建无限的___.framework.loc域。
server {
listen 80;
index index.html index.htm index.php;
# Test 1
server_name ~^(.+)\.frameworks\.loc$;
set $file_path $1;
root /var/www/frameworks/$file_path/public;
include /etc/nginx/php.conf;
}
Run Code Online (Sandbox Code Playgroud)
但是,对于此设置,nginx 会响应 404 错误。我知道 nginx 和 PHP 正在工作并且有权限,因为localhost我使用的配置工作正常。
server {
listen 80 default;
server_name localhost;
root /var/www/localhost;
index index.html index.htm index.php;
include /etc/nginx/php.conf;
}
Run Code Online (Sandbox Code Playgroud)
我应该检查什么才能找到问题?这是他们正在加载的 php.conf 的副本。
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_index index.php;
# …Run Code Online (Sandbox Code Playgroud)