码迷,mamicode.com
首页 > Web开发 > 详细

Mac升级到Yosemite后默认的php版本不支持imagetfftext函数问题解决

时间:2016-08-04 23:14:59      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:

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

Mac升级到Yosemite后默认的php版本不支持imagetfftext函数问题解决

标签:

原文地址:http://www.cnblogs.com/eYeah/p/5738662.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!