首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何更改nginx配置文件路径?

如何更改nginx配置文件路径?
EN

Server Fault用户
提问于 2016-12-17 07:12:51
回答 1查看 30.3K关注 0票数 10

我在ubuntu16.04中安装了nginx,并检查配置文件位置为/etc/nginx/conf/nginx.conf

代码语言:javascript
复制
$ /usr/sbin/nginx -V 2>&1 | grep --colour=auto conf

然后显示配置文件路径:

代码语言:javascript
复制
 --conf-path=/etc/nginx/nginx.conf

我正在安装openam nginx_agent 链接,这个nginx_agent有一个nginx.conf文件

nginx_web_agent安装路径:

代码语言:javascript
复制
   /opt/nginx_agent

nginx_web_agent nginx.conf路径:

代码语言:javascript
复制
   /opt/nginx_agent/conf/nginx.conf

nginx_web_agent使用nginx.conf文件,

如何将nginx默认nginx.conf文件更改为nginx_web_agent nginx.conf文件

例如:

nginx配置使用/opt/nginx_agent/conf/nginx.conf代替/etc/nginx/nginx.conf

建议我怎么做?

EN

回答 1

Server Fault用户

发布于 2016-12-17 08:47:16

/usr/sbin/nginx -V显示初始配置脚本参数,而不一定显示正在运行的实际参数。

要使用替代配置文件,可以设置-c标志(曼尼克斯),而不是默认配置文件:

代码语言:javascript
复制
/usr/sbin/nginx -c /opt/nginx_agent/conf/nginx.conf

Ubuntu16.04使用systemd管理服务,因此需要更改nginx服务的systemd参数:

  1. 编辑/lib/systemd/system/nginx.service
  2. 在需要时添加-c标志: ExecStartPre=/usr/sbin/nginx -t -c /opt/nginx_agent/conf/nginx.conf -q -g‘守护进程on;master_process on;’ExecStart=/usr/sbin/nginx -c /opt/nginx_agent/conf/nginx.conf -g‘守护进程;master_process;’ExecReload=/usr/sbin/nginx -c /opt/nginx_agent/conf/nginx.conf -g‘守护进程;master_process on;’-s重载‘
  3. 重新加载systemd管理器配置:systemctl daemon-reload
  4. 启动nginx服务:服务nginx
  5. 检查nginx服务参数: systemctl状态nginx.service . 2411 nginx:主进程/usr/sbin/nginx -c /opt/nginx_agent/conf/nginx.conf -g守护进程;master_process on .

我就是这样做的。

票数 15
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/821284

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档