Mac10.9仅安装Nginx

首先安装Homebrew

参照Mac安装Homebrew


查看nginx信息

brew info nginx


详细信息如下

nginx: stable 1.4.7 (bottled), devel 1.5.12, HEAD
http://nginx.org/
Not installed
From: https://github.com/Homebrew/homebrew/commits/master/Library/Formula/nginx.rb
==> Dependencies
Required: pcre ✘, openssl ✘
Optional: passenger ✘
==> Options
--with-debug
Compile with support for debug log
--with-gunzip
Compile with support for gunzip module
--with-passenger
Compile with support for Phusion Passenger module
--with-spdy
Compile with support for SPDY module
--with-webdav
Compile with support for WebDAV module
--devel
install development version 1.5.12
--HEAD
install HEAD version
==> Caveats
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.

To have launchd start nginx at login:
    ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents
Then to load nginx now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
Or, if you don't want/need launchctl, you can just run:
    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的欢迎页






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值