首先安装brew brew相当于centos的upgrade和ubuntu的apt-get
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
使用 brew 来安装 nginx 的命令如下:
- 1
安装之后运行:
在浏览器中打开如下地址:
nginx 在 Mac 里安装完成之后它的配置文件如下:
- 1
将 nginx 的端口修改为80,在修改之前先停止 nginx :
- 1
然后用 vim 打开 nginx 的配置文件:
- 1
接下来看到的 nginx 的配置文件如下:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
修改成:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
保存配置并重新运行 nginx :
- 1
在浏览器中打开如下地址:
- 1
如果出现* ERROR 403 Forbidden - * 不必担心, 可能是其他程序比如 skype 占用了 80 端口。
那么意味着我们要用8080端口代替80端口,我们可以使用 http://localhost:8080 来访问nginx。
用 brew 安装的 nginx 的 html 文件夹的默认位置是:
- 1
注意: 将 * 1.2.3 * 修改成你自己的 nginx 版本.
默认配置是:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
我们修改成:
修改完进行检查和重载:sudo /usr/local/bin/nginx -t
sudo /usr/local/bin/nginx -s reload
安装composer
brew install composer
安装的composer可能还不是最新版本的,可以升级一下
composer self-update
可能会报错。代码为:
Error: No available formula with the name "php56-redis" ==> Searching for a previously deleted formula... Error: No previously deleted formula found. ==> Searching for similarly named formulae... Error: No similarly named formulae found. ==> Searching taps... Error: No formulae found in taps.
在brew中添加tap
# brew tap homebrew/homebrew-php
php56-redis 扩展
# brew install php56-redis
就能安装成功了,此过程需要一些时间,大概十分钟左右
安装composer 不要忘了重启nginx
brew install composer