Mac升級到Yosemite後預設的php版本不支援imagetfftext函數問題解決

來源:互聯網
上載者:User

標籤:

Mac升級到yosemite後,php也自動升級,運行項目的時候發現後台驗證碼顯示不出來。調試一下發現imagetfftext這個函數不存在,應該gd沒有安裝完全,因為Mac上的php實現系統內建的,只能通過重新安裝php來解決【不能通過安裝擴充來處理】,經過對比發現使用homebrew安裝會方便點。。。

首先重新安裝freetype,jpeg,libpng,gd
#先刪除之前的再安裝新的,沒有安裝過的則直接跳過即可sudo brew rm freetype jpeg libpng gd zlibbrew install freetype jpeg libpng gd zlib
  • 安裝過程可能會報下面的錯誤:

    Error: You must "brew link libpng" before gd can be installed

    解決辦法:

    #注意添加overwrite,否則可能會提示衝突sudo brew link --overwrite libpng
下來就是安裝php了【這裡安裝會覆蓋之前的php】
#這裡我選擇版本的是php5.6,因為之前系統預設的是php5.5,用高版本的覆蓋放心點sudo brew install homebrew/php/php56
  • 安裝完成之後有如下提示:

    To enable PHP in Apache add the following to httpd.conf and restart Apache:    LoadModule php5_module    /usr/local/opt/php56/libexec/apache2/libphp5.soThe php.ini file can be found in:    /usr/local/etc/php/5.6/php.ini???? PEAR ????If PEAR complains about permissions, ‘fix‘ the default PEAR permissions and config:    chmod -R ug+w /usr/local/Cellar/php56/5.6.10/lib/php    pear config-set php_ini /usr/local/etc/php/5.6/php.ini system???? Extensions ????If you are having issues with custom extension compiling, ensure thatyou are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH: PATH="/usr/local/bin:$PATH"PHP56 Extensions will always be compiled against this PHP. Please install themusing --without-homebrew-php to enable compiling against system PHP.???? PHP CLI ????If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc,~/.zshrc, ~/.profile or your shell‘s equivalent configuration file: export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"???? FPM ????To launch php-fpm on startup: mkdir -p ~/Library/LaunchAgents cp /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plistThe control script is located at /usr/local/opt/php56/sbin/php56-fpmOS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH: PATH="/usr/local/sbin:$PATH"You may also need to edit the plist to use the correct "UserName".Please note that the plist was called ‘homebrew-php.josegonzalez.php56.plist‘ in old versionsof this formula.To have launchd start homebrew/php/php56 at login: ln -sfv /usr/local/opt/php56/*.plist ~/Library/LaunchAgentsThen to load homebrew/php/php56 now: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

上面關鍵的是就是libphp5.so這個檔案,其他的暫時可以忽略了。。。

最後就是修改apache的設定檔【httpd.conf】,把原來的libphp5.so檔案路徑替換為上面的,重啟apache即可 
sudo sudo vim /etc/apache2/httpd.conf#這裡別忘記要替換一下libphp.so的檔案路徑哦sudo apachectl restart




自己測試 sudo brew install homebrew/php/php56 使用這種方式產生的 libphp5.so 檔案的位置不在這段提示的位置"/usr/local/opt/php56/libexec/apache2/libphp5.so" 而是 “/usr/local/Cellar/php56/5.6.23/libexec/apache2/libphp5.so”(自己安裝的是PHP56版本)


from segmentfault.com/a/1190000002924313

Mac升級到Yosemite後預設的php版本不支援imagetfftext函數問題解決

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.