mac 10.9.5 brew安装nginx 1.6.2 php 5.6 及php扩展

1、关闭并删除系统自带的apache

sudo apachectl stop  #关闭apache,如果事先没开启过,可以忽略报错信息

sudo rm /usr/sbin/apachectl
sudo rm /usr/sbin/httpd
sudo rm -r /etc/apache2/


2、删除自带的php

sudo rm -r /usr/bin/php


3、安装 Command Line Tools

xcode-select --install


4、安装brew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
brew update
brew upgrade


5、安装php

brew tap homebrew/dupes
brew tap homebrew/php
brew install php56 --without-apache --with-fpm --with-mysql
添加自启动

mkdir -p ~/Library/LaunchAgents
ln -sfv /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents
为了后面管理方便,将命令 alias 下
nano ~/.bash_aliases
alias php-fpm.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist"
alias php-fpm.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist"
alias php-fpm.restart='php-fpm.stop && php-fpm.start'

 
nano ~/.bash_profile
[[ -f ~/.bash_aliases ]] && . ~/.bash_aliases
source .bash_profile //更新文件
这样就可以用快捷命令来管理php-fpm了

php-fpm.start
php-fpm.stop
php-fpm.restart


6、安装php扩展

brew install php56-redis
brew install php56-amqp


7、安装nginx

brew install nginx
配置nginx

nano /usr/local/etc/nginx/nginx.conf
<pre name="code" class="html">user wby staff;
worker_processes  1;
events {
    worker_connections  128;
}
http {
    include       mime.types;
    include       vhost/*.conf;
    default_type  application/octet-stream;
    sendfile       on;
    tcp_nopush     on;
    tcp_nodelay    on;
    keepalive_timeout  65;
    gzip  on;
}

 
添加vhost
mkdir /usr/local/etc/nginx/vhost

 
nano /usr/local/etc/nginx/vhost/default.conf
server {
        listen       80;
        server_name  zjy;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /Users/wby/Documents/PHPProjects/operator_sz_web/public;
            index  index.html index.htm index.php;
            try_files $uri $uri/ /index.php?$query_string;
        }

        #error_page  404              /404.html;
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /Users/wby/Documents/PHPProjects/public;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ \.php$ {
                fastcgi_intercept_errors on;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  /Users/wby/Documents/PHPProjects/operator_sz_web/public$fastcgi_script_name;
                fastcgi_param  SCRIPT_NAME    $fastcgi_script_name;
                include        /usr/local/etc/nginx/fastcgi_params;
        }
    }
nginx //启动
nginx -s stop   //停止
nginx -s reload  //重新加载


【注意可能会涉及到一些文件和文件夹的用户和权限问题】

【数据库是直接连的服务器,所以我就不装mysql了】

参考了以下内容:

http://tabalt.net/blog/install-nginx-mysql-php-fpm-by-brew-on-mac/
http://blog.frd.mn/install-nginx-php-fpm-mysql-and-phpmyadmin-on-os-x-mavericks-using-homebrew/


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值