根据官网 Building nginx from Sources 的描述,我们可以通过config
命令从源码上构建自己的 nginx。这种方式对我而言显得复杂了,当然是使用 homebrew 来安装啦,它都配置好了。
brew install nginx
安装完毕后运行nginx -h
可以查询帮助,nginx -V
可以显示 nginx 版本及配置选项,我的配置选项如下
- 下面配置选项的意思可以参考 Building nginx from Sources
- 文件路径也要对比瞧瞧,以后遇到问题就根据配置的路径寻找
官网的后面教程提到了
nginx.conf
文件的位置,在我们的系统中,它在/opt/homebrew/etc/nginx/nginx.conf
,这类东西要灵活查找configure arguments: --prefix=/opt/homebrew/Cellar/nginx/1.21.5 --sbin-path=/opt/homebrew/Cellar/nginx/1.21.5/bin/nginx --with-cc-opt='-I/opt/homebrew/opt/pcre/include -I/opt/homebrew/opt/openssl@1.1/include' --with-ld-opt='-L/opt/homebrew/opt/pcre/lib -L/opt/homebrew/opt/openssl@1.1/lib' --conf-path=/opt/homebrew/etc/nginx/nginx.conf --pid-path=/opt/homebrew/var/run/nginx.pid --lock-path=/opt/homebrew/var/run/nginx.lock --http-client-body-temp-path=/opt/homebrew/var/run/nginx/client_body_temp --http-proxy-temp-path=/opt/homebrew/var/run/nginx/proxy_temp --http-fastcgi-temp-path=/opt/homebrew/var/run/nginx/fastcgi_temp --http-uwsgi-temp-path=/opt/homebrew/var/run/nginx/uwsgi_temp --http-scgi-temp-path=/opt/homebrew/var/run/nginx/scgi_temp --http-log-path=/opt/homebrew/var/log/nginx/access.log --error-log-path=/opt/homebrew/var/log/nginx/error.log --with-compat --with-debug --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-ipv6 --with-mail --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module
它都是一行,下面我换行了一下,看得清晰一点
configure arguments:
--prefix=/opt/homebrew/Cellar/nginx/1.21.5
--sbin-path=/opt/homebrew/Cellar/nginx/1.21.5/bin/nginx
--with-cc-opt='-I/opt/homebrew/opt/pcre/include -I/opt/homebrew/opt/openssl@1.1/include'
--with-ld-opt='-L/opt/homebrew/opt/pcre/lib -L/opt/homebrew/opt/openssl@1.1/lib'
--conf-path=/opt/homebrew/etc/nginx/nginx.conf
--pid-path=/opt/homebrew/var/run/nginx.pid
--lock-path=/opt/homebrew/var/run/nginx.lock
--http-client-body-temp-path=/opt/homebrew/var/run/nginx/client_body_temp
--http-proxy-temp-path=/opt/homebrew/var/run/nginx/proxy_temp
--http-fastcgi-temp-path=/opt/homebrew/var/run/nginx/fastcgi_temp
--http-uwsgi-temp-path=/opt/homebrew/var/run/nginx/uwsgi_temp
--http-scgi-temp-path=/opt/homebrew/var/run/nginx/scgi_temp
--http-log-path=/opt/homebrew/var/log/nginx/access.log
--error-log-path=/opt/homebrew/var/log/nginx/error.log
--with-compat
--with-debug
--with-http_addition_module
--with-http_auth_request_module
--with-http_dav_module
--with-http_degradation_module
--with-http_flv_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_mp4_module
--with-http_random_index_module
--with-http_realip_module
--with-http_secure_link_module
--with-http_slice_module
--with-http_ssl_module
--with-http_stub_status_module
--with-http_sub_module
--with-http_v2_module
--with-ipv6
--with-mail
--with-mail_ssl_module
--with-pcre
--with-pcre-jit
--with-stream
--with-stream_realip_module
--with-stream_ssl_module
--with-stream_ssl_preread_module