找回密码
 立即注册
全球项目管理网 首页 产品技术 Mac OSX 查看内容

Mac OSX 10.10.1环境中使用brew安装php5.6.4

2015-2-25 17:18| 发布者: Rain.Qi| 查看: 15| 评论: 0

摘要: Brew 是 Mac 下面的包管理工具,通过 Github 托管适合 Mac 的编译配置以及 Patch

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

安装方法:

使用以下方法可以查看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 php56命令查看安装时可以有哪些选项在选项中会提示是否使用brew安装的相关扩展:

开始安装PHP5.6.4,安装后的php-fpm.ini以及php.ini都在目录:/usr/local/etc/php/5.6/下面

brew install php56 --with-mssql --with-homebrew-openssl --with-homebrew-libxslt --with-homebrew-curl --with-fpm --with-debug --with-gmp --with-imap --with-tidy --with-libmysql --with-pdo-mysql --with-pdo-mysqli --with-pdo-oci --without-snmp --with-mysql

过程中如果出现configure: error: Cannot find OpenSSL's 这样的错误,请执行以下命令,将xcode进行更新:

xcode-select --install

在PHP6安装完成的提示中写到,如何进行PHP6和mac自带的php以及php-fpm替换,执行以下命令后,我们可以看到当前的php版本已经是最新的了:

liondeMacBook-Pro:~ lion$ echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bash_profile liondeMacBook-Pro:~ lion$ echo 'export PATH=/usr/sbin:$PATH' >> ~/.bash_profile liondeMacBook-Pro:~ lion$ echo 'export PATH=/usr/local/sbin:$PATH' >> ~/.bash_profile liondeMacBook-Pro:~ lion$ source ~/.bash_profile liondeMacBook-Pro:~ lion$ php -v
PHP 5.5.15 (cli) (built: Aug 14 2014 15:37:16) (DEBUG) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies liondeMacBook-Pro:~ lion$

使用brew search php56-命令,可以查看还有哪些扩展可以安装,然后执行brew install php56-XXX就可以了。
RainQi-MacBook:local root# brew search php56-
php56-amqp   php56-mcrypt       php56-stats
php56-apcu   php56-mecab       php56-stemmer
php56-augmentedtypes   php56-memcache       php56-suhosin
php56-binpack   php56-memcached       php56-sundown
php56-blitz   php56-midgard2       php56-svm
php56-boxwood   php56-mongo       php56-swoole
php56-chdb   php56-mosquitto       php56-symfony-debug
php56-couchbase   php56-msgpack               php56-thrift
php56-crypto   php56-mysqlnd_ms       php56-tidy
php56-dbase   php56-oauth       php56-timezonedb
php56-dbus   php56-parsekit       php56-tokyotyrant
php56-dmtx   php56-pcntl       php56-twig
php56-eio   php56-pdflib       php56-uploadprogress
php56-ev   php56-pdo-dblib       php56-uuid
php56-event   php56-pdo-pgsql       php56-varnish
php56-gearman   php56-phalcon               php56-vld
php56-geoip   php56-proctitle       php56-wbxml
php56-gmagick   php56-propro       php56-xcache
php56-graphdat   php56-protobuf       php56-xdebug
php56-htscanner   php56-pspell       php56-xhgui
php56-http   php56-pthreads       php56-xhp
php56-igbinary   php56-qr       php56-xhprof
php56-imagick   php56-raphf       php56-xmldiff
php56-inclued   php56-redis       php56-yac
php56-jsmin   php56-riak       php56-yaf
php56-judy   php56-runkit       php56-yaml
php56-leveldb   php56-scrypt       php56-yar
php56-libevent   php56-snappy       php56-yaz
php56-libvirt   php56-solr       php56-yp
php56-lz4   php56-sphinx       php56-yrmcds
php56-lzf   php56-spl-types       php56-zmq
php56-mailparse   php56-ssh2       php56-zookeeper

可以安装的是以下php5.6几个扩展:
brew install brew install php56-redis php56-xdebug php56-mcrypt php56-imagick php56-sphinxphp56-memcache php56-memcached php56-mongo

接下来我们测试php-fpm的配置是否正确,以及是否正确启动:


#测试php-fpm配置是否正确
liondeMacBook-Pro:bin lion$ php-fpm -t
[14-Aug-2014 16:14:30] NOTICE: configuration file /usr/local/etc/php/5.6/php-fpm.conf test is successful

liondeMacBook-Pro:bin lion$ php-fpm -c /usr/local/etc/php/5.6/php.ini -y /usr/local/etc/php/5.6/php-fpm.conf -t
[14-Aug-2014 16:14:48] NOTICE: configuration file /usr/local/etc/php/5.6/php-fpm.conf test is successful

#启动php-fpm
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

#查看9000端口是否在运行
liondeMacBook-Pro:bin lion$ lsof -i:9000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME php-fpm 51241 lion 8u IPv4 0xce9d0f6417637937 0t0 TCP localhost:cslistener (LISTEN) php-fpm 51243 lion 0u IPv4 0xce9d0f6417637937 0t0 TCP localhost:cslistener (LISTEN) php-fpm 51244 lion 0u IPv4 0xce9d0f6417637937 0t0 TCP localhost:cslistener (LISTEN) php-fpm 51245 lion 0u IPv4 0xce9d0f6417637937 0t0 TCP localhost:cslistener (LISTEN)

#关闭掉php-fpm进程,再查看9000端口,没有监听了
liondeMacBook-Pro:bin lion$ ps aux|grep php-fpm|grep -v 'grep'|awk '{print $2}'|xargs kill -9
liondeMacBook-Pro:bin lion$ lsof -i:9000
liondeMacBook-Pro:bin lion$

设置PHP-FPM开机运行
# 设置目录权限
chmod -R ug+w /usr/local/Cellar/php56/5.6.0/lib/php
# 设置pear
pear config-set php_ini /usr/local/etc/php/5.6/php.ini
# 拷贝开机启动文件
cp /usr/local/Cellar/php56/5.6.0/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/
# 启动开机配置
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
# 修改php-fpm的用户组为root
sudo chown root:wheel /usr/local/Cellar/php56/5.6.0/sbin/php-fpm
# 修改php-fpm的权限
sudo chmod u+s /usr/local/Cellar/php56/5.6.0/sbin/php-fpm

设置SESSION 存储目录
/usr/local/etc/php/5.6/php.ini
[Session]
; Handler used to store/retrieve data.
session.save_handler = files
session.save_path = "/usr/local/webserver/session"




鲜花
鲜花
握手
握手
雷人
雷人
路过
路过
鸡蛋
鸡蛋

相关阅读

发表评论

最新评论