如何更改 nginx.conf 文件位置?

 brew install  openresty  --with-debug --conf-path=/usr/local/nginx/conf/nginx.conf

但是它没有效果。

nginx -V
nginx version: openresty/1.9.7.4 (no pool)
built by clang 7.3.0 (clang-703.0.31)
built with OpenSSL 1.0.2h  3 May 2016
TLS SNI support enabled
configure arguments: ......--conf-path=/usr/local/etc/openresty/nginx.conf --http-log-path=/usr/local/var/log/nginx/access.log --error-log-path=/usr/local/var/log/nginx/error.log --with-pcre --with-pcre-jit --with-dtrace-probes --with-http_ssl_module

nginx.conf 文件位置没有改变,仍然是默认值。

点赞
用户2836621
用户2836621

你指定的选项 --conf-path 并不是 homebrew 支持的选项。你可以通过运行以下命令来查看:

brew options openresty

输出

--with-debug
    编译时支持调试日志,但没有适当的 gdb 调试符号。
--with-geoip
    编译时支持 ngx_http_geoip_module 模块。
--with-gunzip
    编译时支持 ngx_http_gunzip_module 模块。
--with-iconv
    编译时支持字符编码转换。
--with-postgresql
    编译时支持直接与 PostgreSQL 数据库服务器通信。
--with-stub_status
    编译时支持 ngx_http_stub_status_module 模块。
--with-webdav
    编译时支持 ngx_http_dav_module 模块。
--without-luajit
    编译时不支持 Lua Just-In-Time 编译器。

我认为你想要做的唯一方法是编辑这个公式,你可以这样做:

brew edit openresty

然后向下搜索 conf-path,并编辑部分如下:

args = [
  "--prefix=#{prefix}",
  "--pid-path=#{var}/run/openresty.pid",
  "--lock-path=#{var}/run/openresty.lock",
  "--sbin-path=#{bin}/openresty",
  "--conf-path=#{etc}/openresty/nginx.conf",        <--- 这里
  "--http-log-path=#{var}/log/nginx/access.log",
  "--error-log-path=#{var}/log/nginx/error.log",
  "--with-pcre",
  "--with-pcre-jit",
  "--with-cc-opt=#{cc_opt}",
  "--with-ld-opt=#{ld_opt}",
]

在运行上述命令之前,您可能需要执行:

brew tap homebrew/nginx
2016-09-01 09:05:34