mac nginx 初次配置的默认路径

mac nginx 初次配置的默认路径

问题描述

mac 上初次配置 nginx,会出现找不见默认路径的情况,以下是总结的默认路径

解决方案

nginx 默认安装的地方(默认的配置文件路径)

/usr/local/etc/nginx

nginx 默认配置文件配置的是 8080 端口,会返回一个默认的 index.html 页面,这个 index.html 页面路径为下

// [version] 为 nginx 的版本

/usr/local/Cellar/nginx/[version]/html

如果是用 brew 安装,则: brew info nginx,则可以得到所有信息

brew info nginx
nginx: stable 1.15.8 (bottled), HEAD
HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server
https://nginx.org/
/usr/local/Cellar/nginx/1.15.8 (23 files, 1.4MB) *
  Poured from bottle on 2019-01-05 at 20:05:47
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/nginx.rb
==> Dependencies
Required: openssl ✔, pcre ✔
Optional: passenger ✘
==> Options
--with-passenger
	Compile with support for Phusion Passenger module
--HEAD
	Install HEAD version
==> Caveats
Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/.

或者是用命令 nginx -V 查看,如下:

nginx -V
nginx version: nginx/1.15.8
built by clang 10.0.0 (clang-1000.11.45.5)
built with OpenSSL 1.0.2q  20 Nov 2018
TLS SNI support enabled
configure arguments: --prefix=/usr/local/Cellar/nginx/1.15.8
--sbin-path=/usr/local/Cellar/nginx/1.15.8/bin/nginx
--with-cc-opt='-I/usr/local/opt/pcre/include -I/usr/local/opt/openssl/include'
--with-ld-opt='-L/usr/local/opt/pcre/lib -L/usr/local/opt/openssl/lib'
--conf-path=/usr/local/etc/nginx/nginx.conf
--pid-path=/usr/local/var/run/nginx.pid
--lock-path=/usr/local/var/run/nginx.lock
--http-client-body-temp-path=/usr/local/var/run/nginx/client_body_temp
--http-proxy-temp-path=/usr/local/var/run/nginx/proxy_temp
--http-fastcgi-temp-path=/usr/local/var/run/nginx/fastcgi_temp
--http-uwsgi-temp-path=/usr/local/var/run/nginx/uwsgi_temp
--http-scgi-temp-path=/usr/local/var/run/nginx/scgi_temp
--http-log-path=/usr/local/var/log/nginx/access.log
--error-log-path=/usr/local/var/log/nginx/error.log
--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
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
### 回答1: 在 Linux 系统上,nginx配置文件默认路径为 /etc/nginx/nginx.conf。如果需要指定其他路径配置文件,可以在启动 nginx 的时候使用 -c 参数,例如: ``` nginx -c /path/to/nginx.conf ``` 其中 /path/to/nginx.conf 是你指定的 nginx 配置文件的绝对路径。注意,如果你使用了 -c 参数指定了配置文件,那么 nginx 不会再去读取默认路径配置文件。 ### 回答2: 要指定Nginx配置文件路径,可以按照以下步骤进行操作: 1. 首先,打开Nginx的安装目录。在Windows系统中,默认的安装路径为"C:\nginx\",而在Linux系统中,默认的安装路径为"/etc/nginx/"。 2. 在Nginx的安装目录中,找到名为"nginx.conf"的配置文件。这个文件是Nginx的主要配置文件,包含了Nginx服务器的全局配置信息和各个虚拟主机的配置。 3. 打开nginx.conf文件,并在其中找到"include"指令。这个指令用于包含其他的配置文件。 4. 可以通过在include指令后面添加配置文件的路径来指定其他配置文件。例如,如果想添加一个名为"myconfig.conf"的配置文件,可以在include指令后面加上路径:"include /path/to/myconfig.conf;"。 5. 保存并关闭nginx.conf文件。 6. 在进行任何配置更改之前,请确保备份原始的nginx.conf文件和新配置文件。 7. 最后,重新启动或重新加载Nginx服务器以使配置更改生效。在Linux系统中,可以使用以下命令重启Nginx:"sudo systemctl restart nginx"。 使用上述步骤,您可以指定Nginx配置文件路径,并在其中添加新的配置文件。这种方法使得配置文件的管理更加灵活,可以根据需求为不同的虚拟主机或不同的站点设置特定的配置。 ### 回答3: 要指定Nginx配置文件路径,首先需要了解Nginx的安装目录。默认情况下,Nginx的主配置文件通常位于`/etc/nginx/nginx.conf`。为了更好地组织Nginx配置文件,可以将它们拆分为多个独立的文件,并在主配置文件中进行引用。 要指定Nginx配置文件路径,可以通过使用命令行选项来实现。通过在启动Nginx时指定特定的配置文件路径,可以覆盖默认配置文件位置。例如,可以使用以下命令启动Nginx并指定配置文件路径: ``` nginx -c /path/to/myconfig.conf ``` 在这个例子中,`/path/to/myconfig.conf`是自定义配置文件的路径Nginx将使用该路径下的配置文件而不是默认的`/etc/nginx/nginx.conf`。 除了单独指定配置文件路径外,还可以通过在配置文件中使用`include`指令来引入其他文件。这样可以进一步拆分和组织配置文件。例如,可以在主配置文件中添加如下指令: ``` include /path/to/other/config.conf; ``` 这将引入`/path/to/other/config.conf`文件中的配置选项。 通过指定配置文件路径或使用`include`指令,可以根据需要更好地组织和管理Nginx配置文件。这有助于提高配置的可读性和维护性。请注意,在修改配置文件后,需要重新加载Nginx以使更改生效。可以使用以下命令重新加载Nginx配置: ``` nginx -s reload ``` 这将重新加载配置文件,以便Nginx使用最新的配置选项。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值