Mac10.9.3仅安装Nginx,mac10.9.3nginx


Mac10.9.3仅安装Nginx

首先安装Homebrew

参照文章 Mac安装Homebrew

查看nginx信息

brew info nginx  

安装nginx

brew install nginx

配置nginx开机启动

ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist

nginx配置文件路径

/usr/local/etc/nginx/nginx.conf  

nginx常用操作

直接启动

nginx   

修改配置后,验证配置文件语法

nginx -t  

nginx运行时直接重启

nginx -s reload  

nginx 启动异常

执行重启命令 nginx -s reload ,出现如下错误

nginx: [error] open() "/usr/local/var/run/nginx.pid" failed (2: No such file or directory) 原因是当前nginx还未启动,先执行 nginx,之后可以执行重启命令

测试安装启动成功

浏览器访问 http://localhost:8080/ 可以看到nginx的欢迎页

如果想让nginx监听 80 端口,启动时要加 sudo

原文地址 http://favoorr.github.io/install-nginx-on-mac/#outline_3

相关内容

    暂无相关文章