brew安装nginx,如何更改nginx.conf文件位置?

时间:2016-09-01 08:03:07

标签: macos nginx homebrew

 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文件位置未更改,仍为默认值。

1 个答案:

答案 0 :(得分:4)

您指定的选项--conf-path不是homebrew支持的选项。你可以通过运行这个来看到:

brew options openresty

<强>输出

--with-debug
    Compile with support for debug logging but without proper gdb debugging symbols
--with-geoip
    Compile with ngx_http_geoip_module
--with-gunzip
    Compile with ngx_http_gunzip_module
--with-iconv
    Compile with support for converting character encodings
--with-postgresql
    Compile with support for direct communication with PostgreSQL database servers
--with-stub_status
    Compile with ngx_http_stub_status_module
--with-webdav
    Compile with ngx_http_dav_module
--without-luajit
    Compile *without* support for the Lua Just-In-Time Compiler

我认为做你想做的事的唯一方法是编辑公式,所以你会这样做:

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",        <--- HERE
  "--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

在运行上述命令之前。