標籤:
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
下來就是安裝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函數問題解決