全新安装Mac OSX 开发者环境 同时使用homebrew搭建 PHP,Nginx ,MySQL,Redis,Memcache ... ... (LNMP开发环境)

原文出处 : 全新安装Mac OSX 开发者环境  非常好的文章  赞

用了一年的Mac OS X了,之前不熟悉这个系统,用的是系统自带的PHP 以及DMG包安装的MySQL,时间长了,慢慢觉得MacBook的速度跟不上了,虽然关机次数不多,但是每次开机,或者唤醒电脑的时候,系统明显有一定时间的卡顿。特别表现在开机的时候。完全可以去泡一个来一桶了。 因此干掉MD101上的光驱,换上256G的Sandisk SSD, 干掉原厂的2G * 2,换上8G * 2 。 速度应该是杠杠的了,至少可以再服役2年吧。
趁着这次加硬盘的机会,就准备彻底重做开发环境。现在对Mac也有了一定的了解,特地记录一下本次的开发环境安装详情,给自己一个备忘,希望也可以帮助到刚接触Mac环境的同学们。本开发环境,全部基于HomeBrew安装。
主要软件版本:PHP5.5.14,Nginx 1.6.0,MySQL5.6.19

OS X Mavericks

重新安装系统,在苹果商店下载好OS X Mavericks安装文件,然后准备一支16G的USB3.0 U盘。制作OS X Mavericks 全新安装启动U盘
插上U盘,在终端执行:sudo /Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/untitled --applicationpath /Applications/Install\ OS\ X\ Mavericks.app --nointeraction
untitled 是你的u盘盘符,根据实际情况来。

Erasing Disk: 0%… 10%… 20%… 30%…100%…
>Copying installer files to disk…
Copy complete.
Making disk bootable…
Copying boot files…
>Copy complete.
>Done.

看到上面的信息说明启动盘制作成功。 安装起来so easy :)

安装完成系统之后, 暂时还没有去迁移文件,由于本人喜好摄影,有大量RAW格式的原图在Aperture 的照片库中,尼康D800一张RAW文件有40M左右,到时候迁移照片库和照片流希望不要掉坑里了。 等开发环境搞定再说了,更新OS X系统到10.9.4 ,然后安装最新的Xcode, 以及在商店买过的软件。确定系统无问题了,进入下一步...

Brew

Brew 是 Mac 下面的包管理工具,通过 Github 托管适合 Mac 的编译配置以及 Patch,可以方便的安装开发工具。 Mac 自带ruby 所以安装起来很方便,同时它也会自动把git也给你装上。官方网站: http://brew.sh 。

安装完成之后,建议执行一下自检,brew doctor如果看到Your system is ready to brew. 那么你的brew已经可以开始使用了。

安装:

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"

自检:

brew doctor

常用命令: (所有软件以PHP5.5为例子)

brew update                        #更新brew可安装包,建议每次执行一下
brew search php55                  #搜索php5.5
brew tap josegonzalez/php          #安装扩展<gihhub_user/repo>   
brew tap                           #查看安装的扩展列表
brew install php55                 #安装php5.5
brew remove  php55                 #卸载php5.5
brew upgrade php55                 #升级php5.5
brew options php55                 #查看php5.5安装选项
brew info    php55                 #查看php5.5相关信息
brew home    php55                 #访问php5.5官方网站
brew services list                 #查看系统通过 brew 安装的服务
brew services cleanup              #清除已卸载无用的启动配置文件
brew services restart php55        #重启php-fpm

注意:brew services 相关命令最好别经常用了,提示会被移除

➜  ~  brew services restart php55
Warning: brew services is unsupported and will be removed soon.
You should use launchctl instead.
Please feel free volunteer to support it in a tap.

Stopping `php55`... (might take a while)
==> Successfully stopped `php55` (label: homebrew.mxcl.php55)
==> Successfully started `php55` (label: homebrew.mxcl.php55)

Oh My Zsh

ohmyzsh & iTerm2两个神器,在Mac os x下是一定要装的. 两组配合起来使用,加上插件。简直是神一样的存在。 秒杀梅西,内马尔啊:) Oh 猛戳到官网

安装 oh my zsh

curl -L http://install.ohmyz.sh | sh

设置默认shell

查看系统支持的shell列表,Mac 10.9.4 自带了 zsh 5.0.2,Linux上得安装。

cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
zsh --version
zsh 5.0.2 (x86_64-apple-darwin13.0)
chsh -s /bin/zsh

虽然Mac自带了zsh,如果你想要最新版的zsh,那么你用 brew install zsh安装一个最新的吧。/usr/local/bin/zsh --version zsh 5.0.5 (x86_64-apple-darwin13.3.0) 区别也不会很大, 默认的版本已经很新了。

homebrew-cask

安装cask:

brew tap phinze/homebrew-cask && brew install brew-cask 

cask常用命令:

brew cask search        #列出所有可以被安装的软件
brew cask search php    #查找所有和php相关的应用
brew cask list          #列出所有通过cask安装的软件
brew cask info phpstorm #查看 phpstorm 的信息
brew cask uninstall qq  #卸载 QQ

这里谈谈cask对比Mac App Store的优势:

  1. 对常用软件支持更全面(特别是开发者),cask里面会给你一些惊喜;
  2. 软件更新速度快,一般都是最新版本 Store上很久很久才会更新版本;
  3. 命令安装感觉比打开Store方便,另外Store在国内的速度也是XXOO。

iTerm2

安装iTerm2:

brew cask install iterm2

上面提过的神器组合,更多使用方法请参考iTerm2官方文档, 这里就不详细说明了。

安装开发常用的包&软件

安装开发包

brew install wget watch tmux cmake openssl imagemagick graphicsmagick gearman geoip readline autoconf multitail source-highlight autojump zsh-completions sshfs 

升级一下系统自带的vim
brew install ctags macvim --env-std --override-system-vim

安装常用软件

brew cask install alfred appcleaner firefox google-chrome phpstorm sublime-text sequel-pro sketch mplayerx thunder qq

Alfred 是个很不错的东西,推荐必须安装。它默认搜索目录不包含brew cask安装的软件,因此手动将/opt/homebrew-cask添加到Alfred的搜索目录

MySQL PHP Nginx Redis Memcache

前面做了这么多的准备工作,其实 zsh iTerm2 brew 等等这些由于篇幅以及能力有限,一时半会也讲不完,更多选择,更多欢乐,就在Google search,现在才入正题。come on :)

安装MySQL

brew install mysql

MySQL开机启动:

ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

======= 安全机制这里,我没有弄 @robby_chan ========

安装完成之后开启MySQL安全机制:

/usr/local/opt/mysql/bin/mysql_secure_installation

根据终端提示,输入root密码,然后依次确认一些安全选项。具体信息可以参考外国友人的这篇文章  .

 ======= 安全机制这里,我没有弄 @robby_chan  end ========

#查看一下MySQL运行情况
➜  ~  ps aux | grep mysql
calvin           1695   0.0  0.5  2719864  90908   ??  S     1:38上午   0:00.31 /usr/local/Cellar/mysql/5.6.19/bin/mysqld --basedir=/usr/local/Cellar/mysql/5.6.19 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql/5.6.19/lib/plugin --bind-address=127.0.0.1 --log-error=/usr/local/var/mysql/CalvinsMacBook-Pro.local.err --pid-file=/usr/local/var/mysql/CalvinsMacBook-Pro.local.pid --socket=/tmp/mysql.sock --port=3306
calvin           1323   0.0  0.0  2444628   1020   ??  S     1:38上午   0:00.04 /bin/sh /usr/local/opt/mysql/bin/mysqld_safe --bind-address=127.0.0.1 --datadir=/usr/local/var/mysql

#测试连接MySQL
mysql -uroot -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 23
Server version: 5.6.19-log Homebrew

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

安装phpmyadmin

brew install phpmyadmin

安装PHP

添加brew的PHP扩展库:

brew update
brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php

可以使用brew options php55命令来查看安装php5.5的选项,这里我用下面的选项安装:

brew install php55 --with-fpm --with-gmp --with-imap --with-tidy --with-debug --with-mysql --with-libmysql

PHP编译过程中如果遇到configure: error: Cannot find OpenSSL's <evp.h>错误,执行xcode-select --install 重新安装一下Xcode Command Line Tools 在GitHub HomeBrew上有关于这个讨论:
For future reference of anybody looking for Command Line Tools with Xcode 5, open up a Terminal window and type xcode-select --install. A window will appear informing you command line tools are required. Click Install and you should be good to go

等待PHP编译完成,开始安装PHP常用扩展,扩展安装过程中brew会自动安装依赖包,例如php55-pdo-pgsql 会自动装上postgresql,这里我安装以下PHP扩展:

下面这里我只安装了 ### robby_chan ###。 并没有安装那么多。
brew install php55-mongo php55-redis php55-xdebug;

brew install php55-apcu\
 php55-gearman\
 php55-geoip\
 php55-gmagick\
 php55-imagick\
 php55-intl\
 php55-mcrypt\
 php55-memcache\
 php55-memcached\
 php55-mongo\
 php55-opcache\
 php55-pdo-pgsql\
 php55-phalcon\
 php55-redis\
 php55-sphinx\
 php55-swoole\
 php55-uuid\
 php55-xdebug;

扩展里面提一下php55-phalcon 和 php55-swoole. 一个是C语言写的PHP框架,安装来个人摸索熟悉一下,还没有真正的使用过,大致看了一下文档,感觉非常吊炸天。目前公司的项目是基于Yii2的,也看看这个框架。 另外一个swoole是国产的PHP高性能网络通信框架,貌似不错,可能在项目中会考虑用到它。

这里我并没有安装那么多  end。

由于Mac自带了php和php-fpm,因此需要添加系统环境变量PATH来替代自带PHP版本。

echo 'export PATH="$(brew --prefix php55)/bin:$PATH"' >> ~/.bash_profile  #for php
echo 'export PATH="$(brew --prefix php55)/sbin:$PATH"' >> ~/.bash_profile  #for php-fpm
echo 'export PATH="/usr/local/bin:/usr/local/sbib:$PATH"' >> ~/.bash_profile #for other brew install soft
source ~/.bash_profile

测试一下效果:

#brew安装的php 他在/usr/local/opt/php55/bin/php
php -v    
PHP 5.5.14 (cli) (built: Jul 16 2014 15:43:06) (DEBUG)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans 

#Mac自带的PHP
/usr/bin/php -v   
PHP 5.4.24 (cli) (built: Jan 19 2014 21:32:15) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

#brew安装的php-fpm 他在/usr/local/opt/php55/sbin/php-fpm
php-fpm -v
PHP 5.5.14 (fpm-fcgi) (built: Jul 16 2014 15:43:12) (DEBUG)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans

#Mac自带的php-fpm
/usr/sbin/php-fpm -v
PHP 5.4.24 (fpm-fcgi) (built: Jan 19 2014 21:32:57)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

修改php-fpm配置文件,vim /usr/local/etc/php/5.5/php-fpm.conf,找到pid相关大概在25行,去掉注释 pid = run/php-fpm.pid, 那么php-fpm的pid文件就会自动产生在/usr/local/var/run/php-fpm.pid,下面要安装的Nginx pid文件也放在这里。

#测试php-fpm配置
php-fpm -t
php-fpm -c /usr/local/etc/php/5.5/php.ini -y /usr/local/etc/php/5.5/php-fpm.conf -t

#启动php-fpm
php-fpm -D
php-fpm -c /usr/local/etc/php/5.5/php.ini -y /usr/local/etc/php/5.5/php-fpm.conf -D

#关闭php-fpm
kill -INT `cat /usr/local/var/run/php-fpm.pid`

#重启php-fpm
kill -USR2 `cat /usr/local/var/run/php-fpm.pid`

#也可以用上文提到的brew命令来重启php-fpm,不过他官方不推荐用这个命令了
brew services restart php55

#还可以用这个命令来启动php-fpm
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist

启动php-fpm之后,确保它正常运行监听9000端口:

lsof -Pni4 | grep LISTEN | grep php
php-fpm   30907 calvin    9u  IPv4 0xf11f9e8e8033a2a7      0t0  TCP 127.0.0.1:9000 (LISTEN)
php-fpm   30917 calvin    0u  IPv4 0xf11f9e8e8033a2a7      0t0  TCP 127.0.0.1:9000 (LISTEN)
php-fpm   30918 calvin    0u  IPv4 0xf11f9e8e8033a2a7      0t0  TCP 127.0.0.1:9000 (LISTEN)
php-fpm   30919 calvin    0u  IPv4 0xf11f9e8e8033a2a7      0t0  TCP 127.0.0.1:9000 (LISTEN)
#正常情况,会看到上面这些进程

PHP-FPM开机启动:

ln -sfv /usr/local/opt/php55/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php55.plist

安装php composer

brew install composer
#检查一下情况
composer --version
Composer version 1.0.0-alpha8 2014-01-06 18:39:59

redis memcached这些软件brew 已经自动依赖安装上,如果想开机自动启动,或者查看使用说明 brew info redis即可。另外,composer的中文文档:猛戳这里

------------- 下面的我就没有再安装了,到此为止。robby_chan end ------------

安装Nginx

brew install nginx --with-http_geoip_module

Nginx启动关闭命令:

#测试配置是否有语法错误
nginx -t

#打开 nginx
sudo nginx

#重新加载配置|重启|停止|退出 nginx
nginx -s reload|reopen|stop|quit

#也可以使用Mac的launchctl来启动|停止
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist

Nginx开机启动

ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist

Nginx监听80端口需要root权限执行,因此:

sudo chown root:wheel /usr/local/Cellar/nginx/1.6.0_1/bin/nginx
sudo chmod u+s /usr/local/Cellar/nginx/1.6.0_1/bin/nginx

配置nginx.conf
创建需要用到的目录:

mkdir -p /usr/local/var/logs/nginx
mkdir -p /usr/local/etc/nginx/sites-available
mkdir -p /usr/local/etc/nginx/sites-enabled
mkdir -p /usr/local/etc/nginx/conf.d
mkdir -p /usr/local/etc/nginx/ssl
sudo mkdir -p /var/www
sudo chown :staff /var/www
sudo chmod 775 /var/www

vim /usr/local/etc/nginx/nginx.conf 输入以下内容:

worker_processes  1;

error_log   /usr/local/var/logs/nginx/error.log debug;


pid        /usr/local/var/run/nginx.pid;


events {
    worker_connections  256;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /usr/local/var/logs/access.log  main;

    sendfile        on;
    keepalive_timeout  65;
    port_in_redirect off;

    include /usr/local/etc/nginx/sites-enabled/*;
}

设置nginx php-fpm配置文件

vim /usr/local/etc/nginx/conf.d/php-fpm
#proxy the php scripts to php-fpm
location ~ \.php$ {
    try_files                   $uri = 404;
    fastcgi_pass                127.0.0.1:9000;
    fastcgi_index               index.php;
    fastcgi_intercept_errors    on;
    include /usr/local/etc/nginx/fastcgi.conf;
}

nginx虚拟主机准备工作

#创建 info.php index.html 404.html 403.html文件到 /var/www 下面
vi /var/www/info.php
vi /var/www/index.html
vi /var/www/403.html
vi /var/www/404.html

创建默认虚拟主机default
vim /usr/local/etc/nginx/sites-available/default输入:

server {
    listen       80;
    server_name  localhost;
    root         /var/www/;

    access_log  /usr/local/var/logs/nginx/default.access.log  main;

    location / {
        index  index.html index.htm index.php;
        autoindex   on;
        include     /usr/local/etc/nginx/conf.d/php-fpm;
    }

    location = /info {
        allow   127.0.0.1;
        deny    all;
        rewrite (.*) /.info.php;
    }

    error_page  404     /404.html;
    error_page  403     /403.html;
}

创建ssl默认虚拟主机default-ssl
vim /usr/local/etc/nginx/sites-available/default-ssl输入:

server {
    listen       443;
    server_name  localhost;
    root       /var/www/;

    access_log  /usr/local/var/logs/nginx/default-ssl.access.log  main;

    ssl                  on;
    ssl_certificate      ssl/localhost.crt;
    ssl_certificate_key  ssl/localhost.key;

    ssl_session_timeout  5m;

    ssl_protocols  SSLv2 SSLv3 TLSv1;
    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;

    location / {
        include   /usr/local/etc/nginx/conf.d/php-fpm;
    }

    location = /info {
        allow   127.0.0.1;
        deny    all;
        rewrite (.*) /.info.php;
    }

    error_page  404     /404.html;
    error_page  403     /403.html;
}

创建phpmyadmin虚拟主机

vim /usr/local/etc/nginx/sites-available/phpmyadmin #输入以下配置
server {
    listen       306;
    server_name  localhost;
    root    /usr/local/share/phpmyadmin;

    error_log   /usr/local/var/logs/nginx/phpmyadmin.error.log;
    access_log  /usr/local/var/logs/nginx/phpmyadmin.access.log main;

    ssl                  on;
    ssl_certificate      ssl/phpmyadmin.crt;
    ssl_certificate_key  ssl/phpmyadmin.key;

    ssl_session_timeout  5m;

    ssl_protocols  SSLv2 SSLv3 TLSv1;
    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;

    location / {
        index  index.html index.htm index.php;
        include   /usr/local/etc/nginx/conf.d/php-fpm;
    }
}

设置SSL

mkdir -p /usr/local/etc/nginx/ssl
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=US/ST=State/L=Town/O=Office/CN=localhost" -keyout /usr/local/etc/nginx/ssl/localhost.key -out /usr/local/etc/nginx/ssl/localhost.crt
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=US/ST=State/L=Town/O=Office/CN=phpmyadmin" -keyout /usr/local/etc/nginx/ssl/phpmyadmin.key -out /usr/local/etc/nginx/ssl/phpmyadmin.crt

创建虚拟主机软连接,开启虚拟主机

ln -sfv /usr/local/etc/nginx/sites-available/default /usr/local/etc/nginx/sites-enabled/default
ln -sfv /usr/local/etc/nginx/sites-available/default-ssl /usr/local/etc/nginx/sites-enabled/default-ssl
ln -sfv /usr/local/etc/nginx/sites-available/phpmyadmin /usr/local/etc/nginx/sites-enabled/phpmyadmin

启动|停止Nginx

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist

接下来你可以通过下面这些连接访问:


http://localhost/ -> index.html
http://localhost/info -> info.php via phpinfo();
http://localhost/404 -> 404.html
https://localhost/ -> index.html(SSL)
https://localhost/info -> info.php via phpinfo();(SSL)
https://localhost/404 -> 404.html(SSL)
https://localhost:306 -> phpmyadmin(SSL)

设置快捷服务控制命令

为了后面管理方便,将命令 alias 下,vim ~/.bash_aliases 输入一下内容:

alias nginx.start='launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist'
alias nginx.stop='launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist'
alias nginx.restart='nginx.stop && nginx.start'
alias php-fpm.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist"
alias php-fpm.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist"
alias php-fpm.restart='php-fpm.stop && php-fpm.start'
alias mysql.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
alias mysql.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
alias mysql.restart='mysql.stop && mysql.start'
alias redis.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.redis.plist"
alias redis.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.redis.plist"
alias redis.restart='redis.stop && redis.start'
alias memcached.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist"
alias memcached.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist"
alias memcached.restart='memcached.stop && memcached.start'
#让快捷命令生效
echo "[[ -f ~/.bash_aliases ]] && . ~/.bash_aliases" >> ~/.bash_profile     
source ~/.bash_profile
#创建站点目录到主目录,方便快捷访问
ln -sfv /var/www ~/htdocs

有时间会进一步整理一下,感觉有点乱,第一次在segmentfault上码字,写到一半的时候不小心滑一下触摸板,浏览器后退了,虽然有提示不要离开,点击了不离开之后,Safari白屏。 然后还特地去吐了个槽, 害我白白又浪费很久来写这个博客。希望能帮助到刚刚接触Mac的同学。enjoy Mac‘s development EVN :)

参考资料:Install Nginx, PHP-FPM, MySQL and phpMyAdmin on OS X Mavericks using Homebrew

 

    讨论区

    •  

      内容详尽,干货~

      #1 zzguo28 · 2014年07月18日 · 回复

    •  
      回复 zzguo28

      国老大过奖了。

      #2 Fish · 2014年07月18日 · 回复

    •  

      刚买mac时也准备装的,后来想想还是算了,不想在mac下装很多东西,还是用vagrent配合vbox来用,随时可以fork多个版本出来

      #3 fifsky · 2014年07月18日 · 回复

    •  

      mark。。

      #4 启程 · 2014年07月18日 · 回复

    •  

      感觉oh my zsh启动相对慢(自动更新已经关了),现在在用prezto,功能似乎也不缺什么,启动速度要快一点。

      另外说到brew-cask还是有不少问题。它是不考虑管理软件的更新问题的,不记录比较版本,没有upgrade和outdated。uninstall命令基本是残废,因此也经常没法用uninstall再install的方式更新。brew-cask作为一个单纯的自动化安装工具还是很好用的,但是只建议用来管理装完了不怎么需要更新、或是自带更新机制很自动化的软件。

      #5 zodiacg · 2014年07月18日 · 回复

    •  

      很详细,mark.

      #6 DeathArmy · 2014年07月18日 · 回复

    •  

      homebrew-cask是没法uninstall。

      #7 mxbyshell · 2014年07月18日 · 回复

    •  

      写的很详细,看完了,就差个Mac了

      #8 苏生不惑 · 2014年07月20日 · 回复

    •  
      回复 fifsky

      还没有用过vagrent 不知道是啥情况。 不过我个人也不需要那么多版本呢。

      #9 Fish · 2014年07月20日 · 回复

    •  
      回复 zodiacg

      1.oh my zsh启动速度的确是慢,以前用机械硬盘的时候更为明显。 现在好一点。 有空我再尝试一下你说的这个prezto
      2.brew-cask的确是适合安装带自动更新的软件, 比如说MacDown

      #10 Fish · 2014年07月20日 · 回复

    •  
      回复 mxbyshell

      我这个版本可以 uninstall呢。不知道你的是什么情况。

      #11 Fish · 2014年07月20日 · 回复

    •  

      最近也准备重装mac,谢谢!

      #12 seeyoup · 2014年07月21日 · 回复

    •  

      D800是重点==

      #13 JohnLui · 2014年07月22日 · 回复

    •  

      这一行 rewrite (.*) /.info.php; 多了一个点…

      #14 h07ch4 · 2014年10月19日 · 回复

    •  

      很棒~~通过这个我终于安装成功了!不过只是用来写写简单的php命令行脚本~~cgi脚本还是建议用vagrant搭个可分享的开发环境来开发~~

      #15 神勇无敌小密探 · 2014年11月06日 · 回复

    •  

      我运行这个命里安装
      brew install php55 --with-fpm --with-gmp --with-imap --with-tidy --with-debug --with-mysql --with-libmysql
      编译安装好后发现在/usr/local/opt/php55/sbin/下面没有php-fpm啊!可能没安装好,要怎么版办?

      #16 davidycx · 2014年11月07日 · 回复

    •  
      回复 davidycx

      应该不可能啊,安装过程报错了吗?bin 下有PHP吗?进去sbin ls | grep fpm 也没有,那就卸载掉PHP,从新安装下吧。

      #17 Fish · 2014年11月07日 · 回复

    •  
      回复 h07ch4

      手误,多谢指出。

      #18 Fish · 2014年11月07日 · 回复

    •  

      我系统是10.10的,之前没有安装mysql就直接安装php55,应该没关系吧!

      #19 davidycx · 2014年11月07日 · 回复

    •  

      干货~ 谢谢分享

      #20 莊虎 · 2014年11月20日 · 回复

    •  

      绝对干货

      #21 guannin · 2014年11月21日 · 回复

    •  

      真不错 等我下次重新装的时候也用一下

      #22 我叫张大熊 · 2014年11月27日 · 回复

    •  

      刚刚入手mac,容我来试试

      #23 JellyBool · 2014年11月28日 · 回复

    •  

      brew install phpmyadmin 这个报brew install phpmyadmin Error: No available formula for phpmyadmin Searching formulae... Searching taps... 怎么搞

      #24 JellyBool · 2014年11月30日 · 回复

    •  

      如何修改php.ini中的date.timezone

      #25 JellyBool · 2014年12月01日 · 回复

    •  

      brew install php55 --with-fpm --with-gmp --with-imap --with-tidy --with-debug --with-mysql --with-libmysql
      一直安装出错,尝试了好多次,看了好多其他的教程,一样是这样。

      /bin/sh: line 1: 17272 Segmentation fault: 11 if test -x "/private/tmp/php55-UV8UL4/php-5.5.20/sapi/cli/php"; then /private/tmp/php55-UV8UL4/php-5.5.20/build/shtool echo -n -- "/private/tmp/php55-UV8UL4/php-5.5.20/sapi/cli/php -n"; if test "x" != "x"; then /private/tmp/php55-UV8UL4/php-5.5.20/build/shtool echo -n -- " -d extension_dir=/private/tmp/php55-UV8UL4/php-5.5.20/modules"; for i in bz2 zlib phar; do if test -f "/private/tmp/php55-UV8UL4/php-5.5.20/modules/$i.la"; then . /private/tmp/php55-UV8UL4/php-5.5.20/modules/$i.la; /private/tmp/php55-UV8UL4/php-5.5.20/build/shtool echo -n -- " -d extension=$dlname"; fi; done; fi; else /private/tmp/php55-UV8UL4/php-5.5.20/build/shtool echo -n -- "/private/tmp/php55-UV8UL4/php-5.5.20/sapi/cli/php"; fi; -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1' -d phar.readonly=0 -d 'safe_mode=0' /private/tmp/php55-UV8UL4/php-5.5.20/ext/phar/build_precommand.php > ext/phar/phar.php
      make: *** [ext/phar/phar.php] Error 139

      READ THIS: http://git.io/brew-troubleshooting
      If reporting this issue please do so at (not Homebrew/homebrew):
      https://github.com/josegonzalez/homebrew-php/issues

      #26 xlong · 1月3日 · 回复

    •  

      感谢分享!“Mac自带php-fpm”让我感到崩溃啊,整了很久~!

      #27 JerryZou · 1月3日 · 回复

    •  
      回复 xlong

      后面加一个 --without-snmp

      #28 terranboy · 1月12日 · 回复

    •  

      cask 官方的安裝方式是:

      $ brew install caskroom/cask/brew-cask 

      差別在哪呢?

      #29 Amo_Wu · 1月13日 · 回复

    •  
      回复 JerryZou

      我现在也遇到这个问题,如何解决

      #30 JellyBool · 2月1日 · 回复

    •  
      php -v  PHP 5.6.5 (cli) (built: Jan 31 2015 00:59:26) (DEBUG) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies with Xdebug v2.2.7, Copyright (c) 2002-2015, by Derick Rethans 
      php-fpm -v  PHP 5.5.14 (fpm-fcgi) (built: Sep 9 2014 19:09:39) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies 

      #31 JellyBool · 2月1日 · 回复

    •  

      如何把自带的php-fpm干掉

      #32 JellyBool · 2月1日 · 回复

    •  
      回复 JellyBool

      我就直接用了系统自带的,没有另外折腾了。。

      #33 JerryZou · 2月2日 · 回复

    •  
      回复 JerryZou

      你php也用系统自带的?

      #34 JellyBool · 2月2日 · 回复

    •  
      回复 JellyBool

      对。我没有用最新版本的强迫症。。

      #35 JerryZou · 2月2日 · 回复

    •  
      回复 JerryZou

      好,我也试试

      #36 JellyBool · 2月2日 · 回复

    •  

      我执行

      php -v PHP 5.6.5 (cli) (built: Feb 2 2015 19:51:09) (DEBUG) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies with Xdebug v2.2.7, Copyright (c) 2002-2015, by Derick Rethans 
      php-fpm -v PHP 5.6.5 (fpm-fcgi) (built: Feb 2 2015 19:51:15) (DEBUG) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies with Xdebug v2.2.7, Copyright (c) 2002-2015, by Derick Rethans 

      得到上面两个,然而我在localhost的php.info的页面中会得到这个php-5.5.14?

      #37 JellyBool · 2月3日 · 回复

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

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

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

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

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

    抵扣说明:

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

    余额充值