- 安装
brew install nginx
brew会自动安装依赖pcre, openssl@1.1,安装路径在/usr/local/homebrew/Cellar/下面,安装过程提示,提示信息的安装路径与启动命令
If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/homebrew/opt/openssl@1.1/bin:$PATH"' >> ~/.bash_profile
/usr/local/homebrew/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.
nginx will load all files in /usr/local/homebrew/etc/nginx/servers/.
To have launchd start nginx now and restart at login:
brew services start nginx
Or, if you don't want/need a background service you can just run:
nginx
/usr/local/homebrew/Cellar/nginx/1.10.3: 8 files, 980.9KB, built in 1 minute 37 seconds
- nginx.conf
- 安装完成后,如果在nginx.conf修改root的路径,有可能会报403,需要chmod修改root指向目录的权限
- 如果开启日志,需要在
/usr/local/homebrew/Cellar/nginx/1.10.3下面创建logs目录
- 启动命令
第1次启动用命令nginx -s reload,重启会碰到pid文件错误,需要用下面的命令
sudo /usr/local/homebrew/Cellar/nginx/1.10.3/bin/nginx
sudo /usr/local/homebrew/Cellar/nginx/1.10.3/bin/nginx -s reload