Mac安装Nginx教程

一、安装nginx首先安装homebrew

1. Homebrew是一款包管理工具,目前支持macOSlinux系统

安装

/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"

卸载(使用官方脚本同样会遇到uninstall地址无法访问问题,可以使用下面脚本:)

/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/uninstall.sh)"

2.配置环境变量

  如果是m1芯片Mac需要手动设置环境变量:

zsh:

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

bash:

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bash_profile
eval "$(/opt/homebrew/bin/brew shellenv)"

m1芯片,可以尝试手动加入环境变量:

zsh

echo 'eval "$(/usr/local/Homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/usr/local/Homebrew/bin/brew shellenv)"

bash

echo 'eval "$(/usr/local/Homebrew/bin/brew shellenv)"' >> ~/.bash_profile
eval "$(/usr/local/Homebrew/bin/brew shellenv)"

二、安装nginx

1. 查询要安装的软件是否存在

brew search nginx  

2.查看安装nginx的信息

brew info nginx

 3.安装

brew install nginx

 然后通过open 进入nginx个配置文件路径

补充:

启动命令: nginx

快速停止命令 nginx -s stop

平稳退出命令:nginx -s quit

重新启动:nginx -s reload

重新加载配置文件命令:nginx -s reload

检查配置文件正确性:nginx -t

查询nginx主进程号:ps -ef | grep nginx

正常停止:kill -QUIT 主进程号

快速停止:kill -TERM 主进程号 /kill -INT 主进程号

强制停止:kill -9 主进程号

猜你喜欢

转载自blog.csdn.net/qq_42717015/article/details/130098477