Mac M3 芯片安装 Nginx

Mac M3 芯片安装 Nginx

一、使用 brew 安装

未安装 brew 的可以参考 【Mac 安装 Homebrew】

或者
【Mac M2/M3 芯片环境配置以及常用软件安装-前端】

二、查看 nginx 信息

通过命令行查看

shell 复制代码
brew info nginx

可以看到 nginx 还未在本地安装,显示 Not installed

三、安装 nginx

shell 复制代码
brew install nginx

四、安装完成之后再使用 brew info nginx 查看信息

bash 复制代码
==> **nginx**: stable 1.25.3 (bottled), HEAD
HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server
https://nginx.org/
/opt/homebrew/Cellar/nginx/1.25.3 (26 files, 2.4MB) *
  Poured from bottle using the formulae.brew.sh API on 2023-11-14 at 09:53:15
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 start nginx now and restart at login:
  brew services start 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: 15,093 (30 days), 43,248 (90 days), 132,256 (365 days)
install-on-request: 15,061 (30 days), 43,157 (90 days), 132,033 (365 days)
build-error: 3 (30 days)

五、查看 nginx 位置

nginxM3 芯片上和 intel 芯片位置不一样,我们可以 open 打开看下

1. M3 芯片
shell 复制代码
/opt/homebrew/etc/nginx/servers/. # 位置
open /opt/homebrew/etc/nginx # 通过 open 打开
2. intel 芯片
bash 复制代码
/usr/local/etc/nginx/

六、nginx启动路径

nginx 启动程序路径,该路径下的 bin/nginx 为启动命令

1. M3 芯片
shell 复制代码
open /opt/homebrew/Cellar/nginx # 打开
2. intel 芯片
shell 复制代码
/usr/local/Cellar/nginx

七、启动 nginx

直接命令行输入 nginx,没有报错即为启动成功

八、浏览器验证

打开浏览器,输入 localhost:8080 并访问,可以显示 Welcome to nginx!

九、nginx 常用命令

命令 解释
nginx 启动 nginx
nginx -s stop 强制停止 nginx 服务
nginx -s quit 退出 nginx 服务
nginx -s reopen 重启 nginx
nginx -s reload 重新加载 nginx 配置文件,然后重启 nginx
nginx -t 测试配置文件的正确性
nginx -v 查看 nginx 版本
nginx -V 查看版本和 nginx 的配置选项
  1. 可以输入 nginx -s quit 再刷新刚刚的 8080 页面看下

  2. 注意 -v -V -t -T 的区别

  • -v shell 显示
bash 复制代码
nginx version: nginx/1.25.3
  • -V shell 显示
shell 复制代码
nginx version: nginx/1.25.3
built by clang 15.0.0 (clang-1500.0.40.1)
built with OpenSSL 3.1.3 19 Sep 2023 (running with OpenSSL 3.1.4 24 Oct 2023)
TLS SNI support enabled
configure arguments: --prefix=/opt/homebrew/Cellar/nginx/1.25.3 ...
  • -t -T 可自实验下
相关推荐
若云止水32 分钟前
Ubuntu 下 nginx-1.24.0 源码分析 - ngx_init_cycle 函数 - 详解(4)
数据库·nginx·ubuntu
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
吃汤圆的抹香鲸1 小时前
Rider 安装包 绿色版 Win/Mac/Linux 适合.NET和游戏开发者使用 2025全栈开发终极指南:从零配置到企业级实战
linux·运维·windows·sql·游戏·macos·.net
Gazer_S2 小时前
【现代前端框架中本地图片资源的处理方案】
前端·javascript·chrome·缓存·前端框架
浪九天4 小时前
Nginx系列05(负载均衡、动静分离)
nginx·运维开发·持续部署
m0_7482365811 小时前
Nginx中$http_host、$host、$proxy_host的区别
运维·nginx·http
2403_8751809512 小时前
AI数字人开发,引领科技新潮流
java·大数据·数据结构·人工智能·科技·前端框架
甜于酸12 小时前
MuMu模拟器Pro for Mac 安卓手机平板模拟器
android·macos·智能手机
渔夫阿布13 小时前
在MAC上面通过HomeBrew安装node和npm@指定版本
前端·macos·npm
web1478621072313 小时前
Linux(CentOS)安装 Nginx
linux·nginx·centos