OS X El Capitan php 5.5.30 覆盖重装 解决 gd 不支持 freetype 的问题 - V2EX
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 3223 次点击
    这是一个创建于 3652 天前的主题,其中的信息可能已经有所发展或是发生改变。
    OS X El Capitan 系统默认的 php 的版本是 5.5.30 gd 是不支持 freetype 的所以 一般的验证码程序都不支持 因为没法使用 imagettftext 函数,现在一般的解决方法是通过 Homebrew 安装其它版本的 php ,不用系统本身自带的。
    br />我是个强迫症,所以找到一条可以通过覆盖安装,不用升级其它扩展到方式的来解决这个问题。
    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 然后有次系统升级丫全给我重置了
    47jm9ozp
        5
    47jm9ozp  
       2015-12-17 15:44:04 +08:00
    我的强迫症和你相反,不是必须的情况不改系统自带的文件

    homebrew 再装一个不就行了, PATH 变量里面自己装的比系统自带的优先就好了。。
    Busy
        6
    Busy  
       2015-12-17 16:34:41 +08:00
    强迫症表示,忍受不了系统文件被修修改改
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     916 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 44ms UTC 20:32 PVG 04:32 LAX 12:32 JFK 15:32
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86