[英]Better VHOST management in Nginx?
My nginx.conf
file is getting larger and large with dozens of vhosts repeating the same lines over and over. 我的nginx.conf
文件越来越大,数十个虚拟主机一遍又一遍地重复相同的行。 I was wondering if there is anyway to declare the following globally without having to repeat them for each project: 我想知道是否有必要在全局范围内声明以下内容,而不必为每个项目重复它们:
# 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;
}
Create a file with the common setup for your vhosts (ie. vhost.conf). 使用您的虚拟主机的通用设置创建一个文件(即vhost.conf)。 Wherever you would like to utilize this common setup, just include that vhost.conf-file. 无论您想在哪里使用此通用设置,只需添加该vhost.conf文件即可。
server {
include vhost.conf
location /test {
# Custom setup for /test
}
}
Paths are relative to your nginx.conf-file, use absolute paths if specifying vhost.conf outside your nginx.conf-path. 路径相对于您的nginx.conf文件,如果在nginx.conf路径之外指定vhost.conf,则使用绝对路径。 http://wiki.nginx.org/NginxHttpMainModule#include http://wiki.nginx.org/NginxHttpMainModule#include
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.