mac+nginx+redis+php+composer的安装和配置

首先安装brew brew相当于centos的upgrade和ubuntu的apt-get

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

使用 brew 来安装 nginx 的命令如下:

brew install nginx
  
  
  • 1

安装之后运行:

sudo nginx

在浏览器中打开如下地址:

http://localhost:8080

nginx 在 Mac 里安装完成之后它的配置文件如下:

/usr/local/etc/nginx/nginx.conf
  
  
  • 1

将 nginx 的端口修改为80,在修改之前先停止 nginx :

sudo nginx -s stop
  
  
  • 1

然后用 vim 打开 nginx 的配置文件:

vim /usr/local/etc/nginx/nginx.conf
  
  
  • 1

接下来看到的 nginx 的配置文件如下:

server {
listen       8080;
server_name  localhost;

#access_log  logs/host.access.log  main;

location / {
    root   html;
    index  index.html index.htm;
}
  
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

修改成:

listen       80;
server_name  localhost;

#access_log  logs/host.access.log  main;

location / {
    root   html;
    index  index.html index.htm;
}
  
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

保存配置并重新运行 nginx :

sudo nginx
  
  
  • 1

在浏览器中打开如下地址:

http://localhost
  
  
  • 1

如果出现* ERROR 403 Forbidden - * 不必担心, 可能是其他程序比如 skype 占用了 80 端口。

那么意味着我们要用8080端口代替80端口,我们可以使用 http://localhost:8080 来访问nginx。

用 brew 安装的 nginx 的 html 文件夹的默认位置是:

 /usr/local/Cellar/nginx/1.2.3/html
  
  
  • 1

注意: 将 * 1.2.3 * 修改成你自己的 nginx 版本.

默认配置是:

server {
listen       80;
server_name  localhost;

#access_log  logs/host.access.log  main;

location / {
    root   html;
    index  index.html index.htm;
}
  
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

我们修改成:

server {
listen       80;
server_name  localhost;

#access_log  logs/host.access.log  main;

location / {
    root   /Users/to/www;
    index  index.html index.htm;
}
修改完进行检查和重载:

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



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值