Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Nginx中更好的VHOST管理?_Php_Nginx_Virtual Hosts - Fatal编程技术网

Php Nginx中更好的VHOST管理?

Php Nginx中更好的VHOST管理?,php,nginx,virtual-hosts,Php,Nginx,Virtual Hosts,我的nginx.conf文件越来越大,几十个vhost一遍又一遍地重复相同的行。我想知道是否有必要在全球范围内声明以下内容,而不必为每个项目重复这些内容: # Route all requests for non-existent files to index.php if (!-e $request_filename) { rewrite ^(.*)$ /index.php/$1 last; } location ~ \.php($|/) { include fastcgi_params

我的
nginx.conf
文件越来越大,几十个vhost一遍又一遍地重复相同的行。我想知道是否有必要在全球范围内声明以下内容,而不必为每个项目重复这些内容:

# Route all requests for non-existent files to index.php
if (!-e $request_filename) {
 rewrite ^(.*)$ /index.php/$1 last;
}

location ~ \.php($|/) {
 include fastcgi_params;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 fastcgi_pass 127.0.0.1:9000;
}

使用vhost的公共设置(即vhost.conf)创建一个文件。无论您想在何处使用此公共设置,只需包含vhost.conf文件即可

server {
    include vhost.conf

    location /test {
        # Custom setup for /test
    }
}

路径是相对于nginx.conf文件的,如果在nginx.conf-path之外指定vhost.conf,请使用绝对路径

使用vhost的通用设置(即vhost.conf)创建一个文件。无论您想在何处使用此公共设置,只需包含vhost.conf文件即可

server {
    include vhost.conf

    location /test {
        # Custom setup for /test
    }
}

路径是相对于nginx.conf文件的,如果在nginx.conf-path之外指定vhost.conf,请使用绝对路径

这个问题很可能更适合serverfault…这个问题很可能更适合serverfault。。。