对macOS因缺少gd库中的freetype而无法打开php验证码进行讨论并提出解决方案
一、采取动态编译的办法在系统自带的php的gd库中增加freetype扩展
友情提示:此方案,尚未行通,macOS自带的php并非用来编程,缺少诸多编程所需文件,此方案难以行通,每走一步都耗费了我大量时间,而后中途改变思路,仅供参考,请勿照做。
安装freetype
brew install freetype
(若没有安装homebrew请进入链接自行安装https://brew.sh/index_zh-cn.html)
php动态编译进入gd目录
cd /usr/local/php5-7.1.10-20171002-090111/include/php/ext/gd
brew install autoconf
sudo phpize
(//http://himill.com/php/804.html
//http://www.mayanlong.com/archives/2016/348.html) //macOS的rootless机制
export PHP_OPENSSL_DIR=yes
sudo ./configure - -with-freetype-dir(config.m4请自行全局搜索,拷贝进gd文件夹中)
//感谢 http://blog.csdn.net/zouqingfang/article/details/52524379 给我主要的思路来源
二、使用homebrew独立安装php(以目前最新版本举例) homebrew的安装请参考方案一
brew install php72 --with-httpd //在方案一的基础上理解--with-httpd已不陌生,安装php时携带安装httpd扩展,是生成php72.so关联apache的必要举措
brew uninstall --ignore-dependencies httpd //消除httpd与php的依赖
brew uninstall httpd //卸载apache,防止与目前已有的冲突
修改httpd.conf配置关联apache与php
LoadModule php7_module /usr/local/opt/php72/libexec/apache2/libphp7.so
brew remove php72 卸载
brew update php72 升级
https://yq.aliyun.com/ziliao/652 //提供些许有用的php扩展安装命令行
- 上一篇:没有了
- 下一篇:没有了