Mac升级到yosemite后,php也自动升级,运行项目的时候发现后台验证码显示不出来。调试一下发现imagetfftext这个函数不存在,应该gd没有安装完全,因为Mac上的php实现系统自带的,只能通过重新安装php来解决【不能通过安装扩展来处理】,经过对比发现使用homebrew安装会方便点。。。

首先重新安装freetype,jpeg,libpng,gd

#先删除之前的再安装新的,没有安装过的则直接跳过即可
sudo brew rm freetype jpeg libpng gd zlib brew install freetype jpeg libpng gd zlib
  • 安装过程可能会报下面的错误:

    Error: You must "brew link libpng" before gd can be installed

    解决办法:

    #注意添加overwrite,否则可能会提示冲突
    sudo brew link --overwrite libpng

下来就是安装php了【这里安装会覆盖之前的php】

#这里我选择版本的是php5.6,因为之前系统默认的是php5.5,用高版本的覆盖放心点
sudo brew install homebrew/php/php56
  • 安装完成之后有如下提示:

    To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so The php.ini file can be found in:
    /usr/local/etc/php/5.6/php.ini ✩✩✩✩ PEAR ✩✩✩✩ If PEAR complains about permissions, 'fix' the default PEAR permissions and config:
    chmod -R ug+w /usr/local/Cellar/php56/5.6.10/lib/php
    pear config-set php_ini /usr/local/etc/php/5.6/php.ini system ✩✩✩✩ 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" PHP56 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/php56)/bin:$PATH" ✩✩✩✩ FPM ✩✩✩✩ To launch php-fpm on startup:
    mkdir -p ~/Library/LaunchAgents
    cp /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/
    launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist The control script is located at /usr/local/opt/php56/sbin/php56-fpm OS X 10.8 and newer come 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.php56.plist' in old versions
    of this formula. To have launchd start homebrew/php/php56 at login:
    ln -sfv /usr/local/opt/php56/*.plist ~/Library/LaunchAgents
    Then to load homebrew/php/php56 now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

上面关键的是就是libphp5.so这个文件,其他的暂时可以忽略了。。。

最后就是修改apache的配置文件【httpd.conf】,把原来的libphp5.so文件路径替换为上面的,重启apache即可

 
sudo sudo vim /etc/apache2/httpd.conf

#这里别忘记要替换一下libphp.so的文件路径哦

sudo apachectl restart

自己测试 sudo brew install homebrew/php/php56 使用这种方式生成的 libphp5.so 文件的位置不在这段提示的位置"/usr/local/opt/php56/libexec/apache2/libphp5.so" 而是 “/usr/local/Cellar/php56/5.6.23/libexec/apache2/libphp5.so”(自己安装的是PHP56版本)

from segmentfault.com/a/1190000002924313

最新文章

  1. windows7 gvim 配置(好用)
  2. [转]acm忠告
  3. mysql数据库、表、字段、记录:增、删、改、查
  4. 阿里云上安装vsftp笔记
  5. win7 dos命令窗口内容显示不全解决办法--将命令执行结果输出到一个文件中
  6. 面试中有关C++的若干问题
  7. process想停就停,真爽
  8. B. Secret Combination
  9. MySql 时间操作实例
  10. Android Material Design(一)史上最全的材料设计控件大全
  11. iOS下JS与原生OC互相调用(总结)
  12. YII框架组件CListView实现分页
  13. [Inside HotSpot] C1编译器优化:全局值编号(GVN)
  14. 1.7分布式工具配置及安装(仅供学习Xshell,VMware)
  15. Docker:镜像构建与进入容器总结
  16. read temperature
  17. Orange Pi 3 GPIO 笔记
  18. thinkphp在wamp 配置去掉url中index.php方法
  19. svn 服务器搭建 ,采用http的方式加密用户。
  20. jubeeeeeat

热门文章

  1. file_get_contents()函数
  2. Android数据库的运用
  3. Js 验证中文字符长度
  4. undefined reference to `_init'问题解决
  5. Dojo特效(翻译)
  6. 【MySQL】分页优化
  7. SparkStreaming(源码阅读十二)
  8. VS里统计整个解决方案代码行数的方法
  9. php中urldecode()和urlencode()
  10. asp.net mvc多条件+分页查询解决方案