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 的影子!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章