V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
myoula
V2EX  ›  PHP

OS X El Capitan php 5.5.30 覆盖重装 解决 gd 不支持 freetype 的问题

  •  
  •   myoula · 2015-12-17 14:43:50 +08:00 · 2598 次点击
    这是一个创建于 3043 天前的主题,其中的信息可能已经有所发展或是发生改变。
    OS X El Capitan 系统默认的 php 的版本是 5.5.30 gd 是不支持 freetype 的所以 一般的验证码程序都不支持 因为没法使用 imagettftext 函数,现在一般的解决方法是通过 Homebrew 安装其它版本的 php ,不用系统本身自带的。

    我是个强迫症,所以找到一条可以通过覆盖安装,不用升级其它扩展到方式的来解决这个问题。
    1 安装 Homebrew
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)";

    2 安装重新编译所需要的依赖库
    brew install autoconf freetype libpng libtool gd jpeg libtiff openssl

    3 做好软链接
    brew link openssl --force

    4 下载 php-5.5.30.tar.gz
    cd ~
    wget http://mirrors.sohu.com/php/php-5.5.30.tar.gz
    tar xzvf php-5.5.30.tar.gz

    5 编译
    cd php-5.5.30
    ./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --sysconfdir=/private/etc --enable-cli --with-config-file-path=/etc --with-config-file-scan-dir=/Library/Server/Web/Config/php --with-libxml-dir=/usr --with-openssl=/usr/local --with-kerberos=/usr --with-zlib=/usr --enable-bcmath --with-bz2=/usr --enable-calendar --disable-cgi --with-curl=/usr --enable-dba --with-ndbm=/usr --enable-exif --enable-fpm --enable-ftp --with-icu-dir=/usr --with-ldap=/usr --with-ldap-sasl=/usr --with-libedit=/usr --enable-mbstring --enable-mbregex --with-mysql=mysqlnd --with-mysqli=mysqlnd --without-pear --with-pear=no --with-pdo-mysql=mysqlnd --with-mysql-sock=/var/mysql/mysql.sock --with-readline=/usr --enable-shmop --with-snmp=/usr --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-tidy --enable-wddx --with-xmlrpc --with-iconv-dir=/usr --with-xsl=/usr --enable-zip --with-apxs2=/usr/sbin/apxs --enable-opcache --with-freetype-dir=/usr/local/Cellar --with-jpeg-dir=/usr/local/Cellar --with-png-dir=/usr/local/Cellar --with-gd

    6 修改 makefile
    vi Makefile
    EXTRA_LIBS 的内容去掉所有的 -lssl -lcrypto ,再加上 ssl crpyto 库的地址
    基本上是以下内容
    EXTRA_LIBS = -lz -lexslt -ltidy -lresolv -ledit -lncurses -lldap -llber -liconv -liconv -lpng -lz -ljpeg -lcurl -lbz2 -lz -lm -lxml2 -lz -licucore -lm -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lcurl -lxml2 -lz -licucore -lm -lfreetype -lxml2 -lz -licucore -lm -lnetsnmp -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lxslt -lm /usr/local/lib/libcrypto.dylib /usr/local/lib/libssl.dylib

    7 编译
    make

    8 关闭系统保护
    重启进入修复模式
    重启后 按 cmd+R
    进入终端控制台 csrutil disable

    9 最后安装
    cd php-5.5.30
    sudo make install

    10 开启系统保护
    重启进入修复模式
    重启后 按 cmd+R
    进入终端控制台 csrutil enable

    end
    6 条回复    2015-12-17 16:34:41 +08:00
    skydiver
        1
    skydiver  
       2015-12-17 14:48:47 +08:00
    你这不是还是覆盖安装了整个 php 么?
    为啥不只覆盖 gd 这个扩展呢?
    myoula
        2
    myoula  
    OP
       2015-12-17 15:04:48 +08:00
    @skydiver 系统自带的 php 是静态编译 gd 库是编译进 php 里的 不是扩展模式
    skydiver
        3
    skydiver  
       2015-12-17 15:08:53 +08:00
    @myoula ╮(╯_╰)╭
    chemzqm
        4
    chemzqm  
       2015-12-17 15:39:11 +08:00
    以前用 mac 自带的 php , 改了些 php.ini 然后有次系统升级丫全给我重置了
    ooxxcc
        5
    ooxxcc  
       2015-12-17 15:44:04 +08:00
    我的强迫症和你相反,不是必须的情况不改系统自带的文件

    homebrew 再装一个不就行了, PATH 变量里面自己装的比系统自带的优先就好了。。
    Havee
        6
    Havee  
       2015-12-17 16:34:41 +08:00
    强迫症表示,忍受不了系统文件被修修改改
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3968 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 10:30 · PVG 18:30 · LAX 03:30 · JFK 06:30
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.