我用 php-fpm 设置了一个 nginx 服务器,想知道如何在我创建的每个新服务器中包含一个文件?EG:此代码位于 /etc/nginx 中名为“server_config.conf”的文件中:
location = /favicon.ico
{
log_not_found off;
access_log off;
}
location = /robots.txt
{
log_not_found off;
access_log off;
}
每个服务器(vhost)都需要包含这个块,我这样做是这样的:
#domain-one.com
server
{
include /etc/nginx/server_config.conf;
server_name domain-one.com www.domain-one.com;
root /var/www/vhosts/domain-one.com/httpdocs;
access_log /var/www/vhosts/domain-one.com/logs/access.log;
error_log /var/www/vhosts/domain-one.com/logs/error.log;
}
# domain-two.com
server
{
include /etc/nginx/server_config.conf;
......
}
是否可以自动获取每个服务器块中包含的“/etc/nginx/server_config.conf”文件,而无需放置“include /etc/nginx/server_config.conf;” 在每个服务器块手动?
谢谢