Mac 安装NginX

1、卸载原有home brew(如果不存在直接进行第二步)

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

2、安装最新版本homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

3、根据信息配置conf文件(无特殊需求默认即可)

Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /usr/local/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

4、将网站目录放到www中

5、运行

sudo nginx -c /usr/local/etc/nginx/nginx.conf
sudo nginx -s reload

6、如果端口被占用,可先杀死进程,再进行第五步。

ps -ef | grep nginx

你可能感兴趣的:(Mac 安装NginX)