资讯专栏INFORMATION COLUMN

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

niceforbear / 415人阅读

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

  

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

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/20995.html

相关文章

  • [未完待续] 在 Mac OS X 中搭建 Apache + PHP + MySQL 开发环境

    摘要:启动打开终端,输入后即可启动。访问会看到字样。启用修改文件的配置,将前面的去掉后,在终端中输入重启后就能够正常使用了不过,用默认的目录开发很是不方便,还好可以自定义工作目录。同样是在文件中,将和中引号内的路径改为自己的路径即可。 我所使用的操作系统是 Mac OS X Yosemite,自带 Apache 和 PHP,所以不用安装,只需稍微修改一下配置文件即可。 启动 Apache ...

    CoorChice 评论0 收藏0
  • [未完待续] 在 Mac OS X 中搭建 Apache + PHP + MySQL 开发环境

    摘要:启动打开终端,输入后即可启动。访问会看到字样。启用修改文件的配置,将前面的去掉后,在终端中输入重启后就能够正常使用了不过,用默认的目录开发很是不方便,还好可以自定义工作目录。同样是在文件中,将和中引号内的路径改为自己的路径即可。 我所使用的操作系统是 Mac OS X Yosemite,自带 Apache 和 PHP,所以不用安装,只需稍微修改一下配置文件即可。 启动 Apache ...

    netmou 评论0 收藏0
  • [译] Laravel 5 之美 - 4) 设置 OS X 或者 Linux 开发机器

    摘要:和使用作为包管理器,使用。除了以外,没有官方的包管理器,但是非官方的包管理器。检查版本要求版本是或更高版本。下载页面安装完毕后,一定要检查版本,确保和在终端可用检查和版本安装是快速开发的一个不可或缺的部分。 原文地址: Laravel 5 Beauty - Setting up an OS X or Linux Machine 让你的 OS X 或者 Linux 机器做好开发 Lara...

    ad6623 评论0 收藏0
  • 解决 font-weight 无效问题

    摘要:因为不同环境下渲染的差异会导致表现不一致。第二个分组用于已知的系统字体针对和。针对和更高版本的操作系统。在和上,并不是显而易见的,而是作为隐藏字体存在。至少切入点有了改变,并不是下无效。 showImg(https://segmentfault.com/img/bVGP7v?w=1392&h=252); 近期调页面时有几个 font-weight 需要修改,无论怎么调整字体粗细都没有变...

    Jrain 评论0 收藏0

发表评论

0条评论

niceforbear

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<