php – 基于主机名的动态nginx域根路径?
发布时间:2020-12-13 13:59:22 所属栏目:PHP教程 来源:网络整理
导读:我正在尝试使用基本的master / catch-all vhost配置来设置我的开发nginx / PHP服务器,以便我可以根据需要使用 created unlimited ___.framework.loc domains. server { listen 80; index index.html index.htm index.php; # Test 1 server_name ~^(.+).fram
|
我正在尝试使用基本的master / catch-all vhost配置来设置我的开发nginx /
PHP服务器,以便我可以根据需要使用
created unlimited
___.framework.loc domains.
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;
}
为什么不使用:
server_name *.frameworks.loc; root /var/www/frameworks/$http_host/public; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |








