Homebrew安装php5及composer for mac教程


安装brew 可以查看教程:mac os x 10.9.1 安装 Homebrew软件包管理工具及brew安装maven3.1.1


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



sudo brew install php55-intl \
--with-debug \
--with-fpm \
--with-gmp \
--with-homebrew-openssl \
--with-imap --with-intl \
--with-libmysql \
--without-bz2 \
--without-mysql \
--without-pcntl \

复制代码 更多的安装选项可以通过 “brew options php55″ 查看。 提示:–with-cgi不能和–with-fpm一起安装,互相冲突 指令执行完后,php 跟 php-fpm 就安装好了。

由于是重装php,之前系统预装的php还没卸载,因此在终端调用php时,还是以之前系统的php版本做解析,所以这里需要修改path,指定 php 的解析路径。在~/.bashrc(没有则创建)最后加入一行:

export PATH="$(brew --prefix php55)/bin:$PATH"


source .bashrc



ls -al /usr/local/bin/php
/usr/local/bin/php -> ../Cellar/php54/5.4.19/bin/php


cat ~/.bash_profile 
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin


HavenShendeMacBook-Air:~ haven$ php -v
PHP 5.5.14 (cli) (built: Jul 18 2014 14:03:26) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies



brew update
brew install josegonzalez/php/composer



  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
Composer version 1.0-dev (1c525b76f81123af180743d31c208c29351cf931) 2015-12-09 15:47:26

  command [options] [arguments]

  -h, --help                     Display this help message
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi                     Force ANSI output
      --no-ansi                  Disable ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --profile                  Display timing and memory usage information
  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  about           Short information about Composer
  archive         Create an archive of this composer package
  browse          Opens the package's repository URL or homepage in your browser.
  clear-cache     Clears composer's internal package cache.
  clearcache      Clears composer's internal package cache.
  config          Set config options
  create-project  Create new project from a package into given directory.
  depends         Shows which packages depend on the given package
  diagnose        Diagnoses the system to identify common errors.
  dump-autoload   Dumps the autoloader
  dumpautoload    Dumps the autoloader
  global          Allows running commands in the global composer dir ($COMPOSER_HOME).
  help            Displays help for a command
  home            Opens the package's repository URL or homepage in your browser.
  info            Show information about packages
  init            Creates a basic composer.json file in current directory.
  install         Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.
  licenses        Show information about licenses of dependencies
  list            Lists commands
  remove          Removes a package from the require or require-dev
  require         Adds required packages to your composer.json and installs them
  run-script      Run the scripts defined in composer.json.
  search          Search for packages
  self-update     Updates composer.phar to the latest version.
  selfupdate      Updates composer.phar to the latest version.
  show            Show information about packages
  status          Show a list of locally modified packages
  suggests        Show package suggestions
  update          Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file.
  validate        Validates a composer.json and composer.lock