您好,欢迎访问一九零五行业门户网

mac环境中使用brew安装php5.5.15

mac本来就自带了 php,但是很多扩展没有安装,所以选择了重新安装php并升级到最新版,下面说说安装步骤,希望对大家有所帮助
brew 是 mac 下面的包管理工具,通过 github 托管适合 mac 的编译配置以及 patch,可以方便的安装开发工具。 mac 自带ruby 所以安装起来很方便,同时它也会自动把git也给你装上。官方网站:
安装方法:
ruby -e $(curl -fssl https://raw.github.com/homebrew/homebrew/go/install)
使用以下方法可以查看brew是否安装成功,以及目前的版本:
liondemacbook-pro:~ lion$ brew -vhomebrew 0.9.5
添加brew的php扩展库:
liondemacbook-pro:~ lion$ brew updateliondemacbook-pro:~ lion$ brew tap homebrew/dupesliondemacbook-pro:~ lion$ brew tap homebrew/phpliondemacbook-pro:~ lion$ brew tap josegonzalez/homebrew-php
可以使用brew options php55命令查看安装时可以有哪些选项,因为我之前安装过curl、libxslt、openssl所以,在选项中会提示是否使用brew安装的相关扩展:
liondemacbook-pro:library lion$ brew options php55--disable-opcache build without opcache extension--disable-zend-multibyte disable auto-detection of unicode encoded scripts (php 5.2 and 5.3 only)--homebrew-apxs build against apxs in homebrew prefix--with-apache enable building of shared apache 2.0 handler module, overriding any options which disable apache--with-cgi enable building of the cgi executable (implies --without-apache)--with-debug compile with debugging symbols--with-fpm enable building of the fpm sapi executable (implies --without-apache)--with-gmp build with gmp support--with-homebrew-curl include curl support via homebrew--with-homebrew-libxslt include libxslt support via homebrew--with-homebrew-openssl include openssl support via homebrew--with-imap include imap extension--with-intl include internationalization support--with-libmysql include (old-style) libmysql support instead of mysqlnd--with-mssql include mssql-db support--with-pdo-oci include oracle databases (requries oracle_home be set)--with-pgsql include postgresql support--with-phpdbg enable building of the phpdbg sapi executable (php 5.4 and above)--with-thread-safety build with thread safety--with-tidy include tidy support--without-bz2 build without bz2 support--without-mysql remove mysql/mariadb support--without-pcntl build without process control support--without-pear build without pear--head install head version
开始安装php5.5.15,安装后的php-fpm.ini以及php.ini都在目录:/usr/local/etc/php/5.5/下面
liondemacbook-pro:library lion$ brew install php55 --with-mssql --with-homebrew-openssl --with-homebrew-libxslt --with-homebrew-curl --with-fpm --with-debug --with-gmp --with-imap --with-tidy --with-libmysql==> installing dependencies for php55: curl, freetds, gmp==> installing php55 dependency: curl==> downloading https://downloads.sf.net/project/machomebrew/bottles/curl-7.37.1.mavericks.bottle.tar.gz######################################################################## 100.0%==> pouring curl-7.37.1.mavericks.bottle.tar.gz==> caveatsthis formula is keg-only, which means it was not symlinked into /usr/local.mac os x already provides this software and installing another version inparallel can cause all kinds of trouble.generally there are no consequences of this for you. if you build yourown software and it requires this formula, you'll need to add to yourbuild variables:ldflags: -l/usr/local/opt/curl/lib cppflags: -i/usr/local/opt/curl/include==> summary /usr/local/cellar/curl/7.37.1: 285 files, 2.8m==> installing php55 dependency: freetds==> downloading ######################################################################## 100.0%==> ./configure --prefix=/usr/local/cellar/freetds/0.91 --with-openssl=/usr/local/opt/openssl --with-tdsver=7.1 --mandir=/usr==> make==> make install /usr/local/cellar/freetds/0.91: 600 files, 9.9m, built in 2.2 minutes==> installing php55 dependency: gmp==> downloading https://downloads.sf.net/project/machomebrew/bottles/gmp-6.0.0a.mavericks.bottle.tar.gz######################################################################## 100.0%==> pouring gmp-6.0.0a.mavericks.bottle.tar.gz /usr/local/cellar/gmp/6.0.0a: 15 files, 3.2m==> installing php55==> downloading already downloaded: /library/caches/homebrew/php55-5.5.15==> ./configure --prefix=/usr/local/cellar/php55/5.5.15 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc/php/5.5 --==> make==> make install==> /usr/local/cellar/php55/5.5.15/bin/pear config-set php_ini /usr/local/etc/php/5.5/php.ini==> caveatsthe php.ini file can be found in: /usr/local/etc/php/5.5/php.ini✩✩✩✩ pear ✩✩✩✩if pear complains about permissions, 'fix' the default pear permissions and config: chmod -r ug+w /usr/local/cellar/php55/5.5.15/lib/php pear config-set php_ini /usr/local/etc/php/5.5/php.ini✩✩✩✩ extensions ✩✩✩✩if you are having issues with custom extension compiling, ensure thatyou are using the brew version, by placing /usr/local/bin before /usr/sbin in your path:path=/usr/local/bin:$pathphp55 extensions will always be compiled against this php. please install themusing --without-homebrew-php to enable compiling against system php.✩✩✩✩ php cli ✩✩✩✩if you wish to swap the php you use on the command line, you should add the following to ~/.bashrc,~/.zshrc, ~/.profile or your shell's equivalent configuration file:export path=$(brew --prefix homebrew/php/php55)/bin:$path✩✩✩✩ fpm ✩✩✩✩to launch php-fpm on startup: * if this is your first install:mkdir -p ~/library/launchagentscp /usr/local/cellar/php55/5.5.15/homebrew.mxcl.php55.plist ~/library/launchagents/launchctl load -w ~/library/launchagents/homebrew.mxcl.php55.plist* if this is an upgrade and you already have the homebrew.mxcl.php55.plist loaded:launchctl unload -w ~/library/launchagents/homebrew.mxcl.php55.plistcp /usr/local/cellar/php55/5.5.15/homebrew.mxcl.php55.plist ~/library/launchagents/launchctl load -w ~/library/launchagents/homebrew.mxcl.php55.plistthe control script is located at /usr/local/cellar/php55/5.5.15/sbin/php55-fpmmountain lion comes with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your path:path=/usr/local/sbin:$pathyou may also need to edit the plist to use the correct username.please note that the plist was called 'homebrew-php.josegonzalez.php55.plist' in old versionsof this formula.to have launchd start php55 at login: ln -sfv /usr/local/opt/php55/*.plist ~/library/launchagentsthen to load php55 now: launchctl load ~/library/launchagents/homebrew.mxcl.php55.plist==> summary /usr/local/cellar/php55/5.5.15: 477 files, 43m, built in 3.9 minutes
过程中如果出现configure: error: cannot find openssl's 这样的错误,请执行以下命令,将xcode进行更新:
xcode-select --install
在php5安装完成的提示中写到,如何进行php5和mac自带的php以及php-fpm替换,执行以下命令后,我们可以看到当前的php版本已经是最新的了:
其它类似信息

推荐信息