我正在尝试使用基本的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;
}
但是,对于此设置,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;
}
我应该检查什么才能发现问题?这是它们都正在加载的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;
# Keep these parameters for compatibility with old PHP scripts using them.
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# Some default config
fastcgi_connect_timeout 20;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_pass 127.0.0.1:9000;
}