安装说明
brew install nginx
Docroot在 /usr/local/var/www
因为我不是用root用户安装的,所以关闭和启动nginx,都要加上sudo;如果不想加sudo,可以将usr/local/etc/nginx/nginx.conf
中的默认端口改为8080
Nginx会加载/usr/local/etc/nginx/servers/
下的所有文件,该目录下可以自定义一些虚拟主机,另一篇文章中会介绍。
设置开机启动
ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
不想开机启动,就执行
nginx
或sudo nginx
常用命令
-t : test configuration and exit
-s signal : send signal to a master process: stop, quit, reopen, reload
eg:
sudo nginx -s stop //参数可以有stop,quit,reopen
sudo nginx //启动
sudo killall -9 nginx //关闭nginx所有进程
sudo nginx -t -c /usr/local/etc/nginx/nginx.conf //测试配置文件的语法是否正确