原因:系统自带的php 缺少gd库
解决办法:使用brew 安装php
下面是网上找的一些文章 但是无法编译得到 libphp5.so 这个库
然后我们来修改下文章
所以操作步骤如下:
1、安装brew(已经安装的略过)
2、安装php5.6
3、安装freetype
,jpeg
,libpng
,gd
,zlib
具体过程:
安装homebrew
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
这里由于网速原因估计会比较慢
完成后,接下来自检一下:
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: A newer Command Line Tools release is available.
Update them from Software Update in the App Store.
出现一些警告信息,其中也说明了如果brew运行正常就不用管它。CTRL+C退出,继续往下
配置第三方源
因为homebrew没有自带php的包,所以要添加新的源进来:
$ brew tap homebrew/dupes
$ brew tap homebrew/versions
$ brew tap homebrew/homebrew-php
安装php
install安装
brew install php56 --with-apache --with-homebrew-curl
安装过程需要一段时间,等一下就可以了。
如果遇到configure: error: Cannot find libz
解决方法 执行
xcode-select --install
然后再使用 下面命令安装就
brew install php56 --with-apache --with-homebrew-curl
安装freetype
,jpeg
,libpng
,gd
,zlib
然后创建链接
配置apache支持新安装的php
sudo vim /etc/apache2/httpd.conf
LoadModule php5_module /usr/local/Cellar/php56/5.6.31_7/libexec/apache2/libphp5.so
不要忘记重新启动下apache
sudo /usr/sbin/apachectl restart
重启完成后,看看验证码是否显示了