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。。。