我有一个名为default-site的nginxconfiguration文件,如下所示:
server { ... }
在我的文档文件夹中的某处。 是否可以使用此configuration文件运行服务器,而不是将其放在默认的/usr/local/etc/nginx/nginx.conf ?
我尝试使用-c标志,如下所示:
sudo nginx -c ~/Documents/trustfactors/analytics/infra-ansible/roles/nginx/files/default-site
但我得到的错误:
nginx: [emerg] "server" directive is not allowed here in /Users/william/Documents/trustfactors/analytics/infra-ansible/roles/nginx/files/default-site:5
您没有完整的nginxconfiguration,只有虚拟服务器configuration。 您需要现有nginx.conf的副本,您将在其中包含此configuration文件。