mac 上 php 验证码不显示图片

20190718 学习做一个 thinkphp5 的验证码,结果发现在我的 macbook 上死活不出图片,但是在windows 上是可以的!断定问题出在环境上!

macOS Mojave 10.14.5 
WEB: 自带的 apache
PHP:自带的 php 7.1

经过了一大圈重装 apache 和 php 之后,终于是出来了!

1、 现状

2、之前是这样的

3、记录一下分析和解决的过程

重装 apache 和 php 的过程分别记录在了
MacBook 重装 Apache 和 PHP 7.2
https://blog.csdn.net/u010953609/article/details/96474165
Mac 重装 Apache 后中文目录乱码
https://blog.csdn.net/u010953609/article/details/96479940
macbook 系统 php 版本和 web 的 php 版本不一样,brew link php 失败
https://blog.csdn.net/u010953609/article/details/96480355

以上 3 个实际上和 php 代码没有什么关系!

  1. $ brew info gd

     gd: stable 2.2.5 (bottled), HEAD
     Graphics library to dynamically manipulate images
     https://libgd.github.io/
     Not installed
     From: https://mirrors.ustc.edu.cn/homebrew-core.git/Formula/gd.rb
     ==> Dependencies
     Required: fontconfig ✘, freetype ✘, jpeg ✘, libpng ✔, libtiff ✘, webp ✘
     ==> Options
     --HEAD
     	Install HEAD version
    

把以上 打X 的一个一个安装上!

brew install fontconfig
brew install freetype
brew install jpeg
brew install libtiff
brew install webp

一个一个确认一下

brew info freetype
brew info jpeg
brew info libpng
brew info zlib

	zlib: stable 1.2.11 (bottled) [keg-only]
	General-purpose lossless data-compression library
	https://zlib.net/
	Not installed
	From: https://mirrors.ustc.edu.cn/homebrew-core.git/Formula/zlib.rb
	==> Caveats
	This formula is keg-only, which means it was not symlinked into /usr/local,
	because macOS already provides this software and installing another version in
	parallel can cause all kinds of trouble.

再次安装
brew install zlib

  1. 发现问题出在 freetype
    brew install freetype
    Updating Homebrew…
    Warning: freetype 2.9.1 is already installed, it’s just not linked
    You can use brew link freetype to link this version.

  2. brew link freetype

     Linking /usr/local/Cellar/freetype/2.9.1... 
     Error: Could not symlink share/aclocal/freetype2.m4
     /usr/local/share/aclocal is not writable.
    
  3. 再来
    $ sudo chmod -R 777 aclocal
    $ brew link freetype
    Linking /usr/local/Cellar/freetype/2.9.1… 8 symlinks created

  4. $ sudo apachectl restart
    正以为一切 ok 的时候,却绝望的发现一切依然!

这才有了以上折腾一大圈!重装 apache!重装 php!

4、 经验总结:

  1. 是否支持 freetype ,光从命令行 php -m 和以上 brew install ,brew info 是不行的!

  2. Mac 系统太顽固了!
    系统中的 freetype 不一定就加载到了 apache !
    据说这是新版内置 apache 才开始的,以前的版本没有这个问题!

  3. 判断 WEB 是否支持 freetype,只有这样子 phpinfo 去查看

之前的图没有保存!但是,确实记得,没有找到 freetype 的影子!

发布了69 篇原创文章 · 获赞 10 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/u010953609/article/details/96482861