mac下安装nginx

一、安装 Nginx

  1. 终端执行:
brew search nginx
brew install nginx

当前版本 1.10.2,通过brew可以把nginx需要的pcre,openssl,zlib全部一键装好。

mac下安装nginx

安装完以后,可以在终端输出的信息里看到一些配置路径:

/usr/local/etc/nginx/nginx.conf (配置文件路径)

/usr/local/var/www (服务器默认路径)

/usr/local/Cellar/nginx/1.10.2_1  (安装路径)

执行nginx -V可以看到安装配置过程的一些选项,能自动化安装,就不要手动安装,不然会有各种出乎意料的问题。

mac下安装nginx

可以通过执行ps -ef | grep nginx快速查看nginx master进程的pid,通过kill来关闭,通过执行nginx -c /user/local/etc/nginx/nginx.conf来重新打开


二、访问localhost:8080

Nginx 默认8080端口,这时已经可以访问了:

localhost:8080

会有一个默认欢迎界面。

mac下安装nginx