本地使用Nginx

1. 首先检查当前电脑是否安装了 brew

  1. brew -v
  2. // 如果没有安装则执行以下命令,安装brew
  3. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2. brew安装nginx

  1. brew search nginx
  2. // 如果没有安装 nginx,则使用以下命令来安装
  3. brew install nginx

image.png

  1. Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)!
  2. # 安装
  3. arch -arm64 brew install Nginx
  4. # 查看
  5. brew info nginx

image.png
在安装的信息中有这些数据

  1. The default port has been set in /opt/homebrew/etc/nginx/nginx.conf to 8080 so that
  2. nginx can run without sudo.
  3. nginx will load all files in /opt/homebrew/etc/nginx/servers/.

nginx配置文件在

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

nginx 的启动:

  1. // 以下命令当提醒没有权限时,命令行前加 sudo
  2. // nginx的启动
  3. nginx
  4. // 查看当前 nginx 运行的进程
  5. ps -ef | grep nginx
  6. // 关闭某一个进程
  7. kill [进程编号]
  8. // 快速停止 nginx 进程
  9. nginx -s stop
  10. // 重启 nginx
  11. nginx -s reload
  12. // 搜索当前目录下有关键字 abc nginx配置文件
  13. grep abc * -r