MAC安装nginx,并解决80端口占用问题
安装nginx
mac上的包管理工具HomeBrew非常好用,一般通过这种方式安装nginx
若mac没有安装HomeBrew,建议安装
安装nginx
brew install nginx
启动nginx
sudo nginx
关闭nginx
sudo nginx -s stop
重启nginx
sudo nginx -s relaod
或者
sudo nginx -s restart
安装HomeBrew
终端运行
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
解决80端口占用,导致nginx启动失败
打开nginx的配置文件
文件地址
/usr/local/etc/nginx/nginx.conf
server {
listen 80;
server_name localhost;
}
先将监听端口设置为一个不被占用的端口,如8080等
再次启动nginx
若启动成功,修改配置文件,监听80端口,运行重载命令即可
sudo nginx -s relaod