homebrew安装nginx
Homebrew 是一款自由及开放源代码的软件包管理系统,用以简化 macOS 和 linux 系统上的软件安装过程。它拥有安装、卸载、更新、查看、搜索等很多实用的功能,通过简单的一条指令,就可以实现包管理,十分方便快捷。
Homebrew 主要有四个部分组成: brew、homebrew-core 、homebrew-bottles、homebrew-cask。
替换为阿里源
查看 brew.git 当前源
cd "$(brew --repo)" && git remote -v
查看 homebrew-core.git 当前源
cd "$(brew --repo homebrew/core)" && git remote -v
修改 brew.git 为阿里源
git -C "$(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
修改 homebrew-core.git 为阿里源
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
zsh 替换 brew bintray 镜像
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
bash 替换 brew bintray 镜像
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
刷新源
brew update
配置信息地址
nginx配置文件地址
cd /usr/local/etc/nginx/
vim nginx.conf
nginx错误日志地址
一般会在上述配置文件的头部会标明错误日志文件夹:
error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;
但是在这之前,你得在 /usr/local/Cellar/nginx/1.xx 下新建 logs 日志文件夹。
部分报错解决
报错:directory index of “xxx“ is forbidden
这时候,可以在/etc/nginx/nginx.conf中添加配置(添加至server模块中):
...
listen 8080;
server_name localhost;
autoindex on;
...
nginx: [warn] 1024 worker_connections exceed open file resource limit: 256
在mac上启动nginx 会有警告输出
nginx: [warn] 1024 worker_connections exceed open file resource limit: 256
输入命令:
ulimit -n 1024
下次启动就不会有这个警告了。
也可以加入到 /etc/profile 中永久生效
部分常见命令
开始:nginx
重启:ngix -s reload
快速停止:nginx -s quit