Mac升级到Yosemite后默认的php版本不支持imagetfftext函数问题解决
生活随笔
收集整理的這篇文章主要介紹了
Mac升级到Yosemite后默认的php版本不支持imagetfftext函数问题解决
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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/phppear config-set php_ini /usr/local/etc/php/5.6/php.ini system???? Extensions ????If you are having issues with custom extension compiling, ensure that you 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 them using --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/LaunchAgentscp /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 versions of this formula.To have launchd start homebrew/php/php56 at login:ln -sfv /usr/local/opt/php56/*.plist ~/Library/LaunchAgents Then 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總結
以上是生活随笔為你收集整理的Mac升级到Yosemite后默认的php版本不支持imagetfftext函数问题解决的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PHP中全局变量的使用global和$G
- 下一篇: 调优 PHP