brew php5,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 -v

Homebrew 0.9.5

添加brew的PHP扩展库:

liondeMacBook-Pro:~ lion$ brew update

liondeMacBook-Pro:~ lion$ brew tap homebrew/dupes

liondeMacBook-Pro:~ lion$ brew tap homebrew/php

liondeMacBook-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

==> Caveats

This formula is keg-only, which means it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in

parallel can cause all kinds of trouble.

Generally there are no consequences of this for you. If you build your

own software and it requires this formula, you'll need to add to your

build 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

==> Caveats

The 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 that

you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH:

PATH="/usr/local/bin:$PATH"

PHP55 Extensions will always be compiled against this PHP. Please install them

using --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/LaunchAgents

cp /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.plist

cp /usr/local/Cellar/php55/5.5.15/homebrew.mxcl.php55.plist ~/Library/LaunchAgents/

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

The control script is located at /usr/local/Cellar/php55/5.5.15/sbin/php55-fpm

Mountain 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:$PATH"

You 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 versions

of this formula.

To have launchd start php55 at login:

ln -sfv /usr/local/opt/php55/*.plist ~/Library/LaunchAgents

Then 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版本已经是最新的了:

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值