nginx实战之macos安装使用

作者:Administrator 发布时间: 2024-10-18 阅读量:9 评论数:0

nginx实战之macos安装使用

场景

系统:MacOS 15
安装方式:homebrew

安装步骤

1.安装主程序

homebrew install nginx

2.配置主文件位置

/opt/homebrew/etc/nginx/nginx.conf

3.默认html主页位置

/opt/homebrew/var/www
注:这里是做的软连接 html -> ../../../var/www
/opt/homebrew/Cellar/nginx/1.27.2/html

4.重启命令

brew services restart nginx

5.关闭开机自动启动

/opt/homebrew/opt/nginx/bin/nginx -g daemon\ off;

或者
在配置文件的顶部或 http 块中添加:
daemon off;
然后重启即可。

6.查看安装路径

brew info nginx

==> nginx: stable 1.27.2 (bottled), HEAD
HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server
https://nginx.org/
Installed
/opt/homebrew/Cellar/nginx/1.27.2 (29 files, 2.5MB) *
  Poured from bottle using the formulae.brew.sh API on 2024-10-17 at 23:04:00
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/n/nginx.rb
License: BSD-2-Clause
==> Dependencies
Required: openssl@3 ✔, pcre2 ✔
==> Options
--HEAD
	Install HEAD version
==> Caveats
Docroot is: /opt/homebrew/var/www

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

nginx will load all files in /opt/homebrew/etc/nginx/servers/.

To restart nginx after an upgrade:
  brew services restart nginx
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/nginx/bin/nginx -g daemon\ off\;
==> Analytics
install: 14,730 (30 days), 42,728 (90 days), 162,944 (365 days)
install-on-request: 14,717 (30 days), 42,663 (90 days), 162,477 (365 days)
build-error: 20 (30 days)

欢迎关注我的公众号“辣个男人Devin”,新鲜技术文章第一时间推送。

评论