mac 的Nginx安装

512 阅读1分钟

一、 Brew 安装:

/bin/zsh -c "$(curl -fsSL gitee.com/cunkai/Home…)" 进而可以更换镜像源文件,选择中科大的镜像即可。 具体使用方法可以通过brew -h来进行查看:

1、检查nginx是否存在

brew search nginx 

2、重要!后面配置 方便很多

brew info nginx

3、安装

brew install nginx

 /usr/local/Cellar/nginx/1.23.1  安装路径,在安装nginx 成功时就会出现

4、环境变量配置

mac 环境变量

在 ~/.bash_profile 中添加一行:

启动终端Terminal,直接输入~/.bash_profile
会显示 No such file or directory  请参考bash_profile 文件用来配置环境变量

NGINX_HOME=/usr/local/nginx /  / nginx 安装路径

export PATH=PATH:PATH:NGINX_HOME/sbin

其中,/usr/local/bin 为需要添加的 path

执行

source .bash_profile

生效

在 .base_profile 中还可以设置命令别名,如

登录后复制 

alias ll='ls -l'

alias p1='cd ~/codes/project1'

bash_profile 文件用来配置环境变量

第一种方式:
启动终端Terminal,直接输入~/.bash_profile
会显示 No such file or directory

进入当前用户的home目录
输入cd ~

创建.bash_profile
输入touch .bash_profile

打开编辑.bash_profile文件
输入open -e .bash_profile

保存文件,关闭.bash_profile

更新刚配置的环境变量
输入source .bash_profile

在.bash_profile文件为锁定状态的时候,第一种方式是不可行的,那么用第二种方式来编辑.bash_profile文件

第二种方式
第二种方式,在Terminal终端通过指令来对.bash_profile文件进行编辑

输入 vim .bash_profile

输入 i 进行编辑模式

然后把需要编辑的内容键入,编辑完之后直接按esc退出编辑模式,

输入:w进行文件的保存,:wq为保存并退出指令