Mac下Nginx安装教程

反向代理服务器。

准备

需要使用包管理器 brew,可查看brew安装教程 Mac包管理工具brew的安装、使用及换源

安装

# 安装
$ brew install nginx
...

# 查看brew list 是否存在 nginx
$ brew list
nginx

# 使用 brew 启动 nginx
$ brew services start nginx
brew services start nginx
$ brew services list
Name  Status  User      Plist
nginx started caoyucong /Users/caoyucong/Library/LaunchAgents/homebrew.mxcl.nginx.plist

# 使用 nginx 自带命令
nginx -t          # 检查配置文件是否通过
nginx -s reload   # 重启

浏览器输入 http://localhost:8080/ 看到启动成功。

查看 nginx.conf 目录

$ find /|grep nginx.conf
/usr/local/etc/nginx/nginx.conf.default
/usr/local/etc/nginx/nginx.conf
/usr/local/Cellar/nginx/1.17.10/.bottle/etc/nginx/nginx.conf.default
/usr/local/Cellar/nginx/1.17.10/.bottle/etc/nginx/nginx.conf

查看 nginx 使用的 nginx.conf 目录

$ nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful

查看 nginx 环境配置

$ nginx -V
nginx version: nginx/1.17.10
built by clang 11.0.0 (clang-1100.0.33.17)
built with OpenSSL 1.1.1f  31 Mar 2020 (running with OpenSSL 1.1.1g  21 Apr 2020)
TLS SNI support enabled
configure arguments: --prefix=/usr/local/Cellar/nginx/1.17.10 --sbin-path=/usr/local/Cellar/nginx/1.17.10/bin/nginx
...

如何配置 nginx.conf 查看文章:Nginx配置Web项目(多页面应用,单页面应用)


whosmeya.com

原文地址:https://www.cnblogs.com/whosmeya/p/13114498.html