nginx的配置比较简单,安装测试结束主要分以下五步:
1.安装Homebrew
终端输入:ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
2.安装nginx
终端输入:brew install nginx
如果安装失败出现:Error:
homebrew-core is a shallow clone.
To brew update
, first run:
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
执行命令:
a.cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
b.git fetch
c.git fetch --unshallow
d.brew update
如果安装失败出现:Error: Failure while executing; git clone https://github.com/Homebrew/homebrew-services /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services --origin=origin
exited with 128.
Error: Failure while executing; /usr/local/bin/brew tap homebrew/services
exited with 1.
执行命令:
a.git config --global --unset http.proxy
b.git config --global --unset https.proxy
c.brew install nginx
安装成功后执行命令:brew services start nginx
访问: http://localhost:8080/
3.修改 NGINX.CONF
vi /usr/local/etc/nginx/nginx.conf
配置好后重启nginx,执行命令nginx -s relaod
4.测试:
网页上输入http://localhost:8090
5.关闭nginx
nginx -s stop