![](/img/trans.png)
[英]Error executing php files after upgrading to mac os x Mavericks 10.9
[英]PHP Xdebug on OS X 10.9 Mavericks
在安裝OS X 10.9 Mavericks后,我在OS X上設置PHP開發環境時遇到問題。
這是我用來安裝的命令。
sudo pecl install xdebug
downloading xdebug-2.2.3.tgz ...
Starting to download xdebug-2.2.3.tgz (250,543 bytes)
.....................................................done: 250,543 bytes
66 source files, building
running: phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
ERROR: `phpize' failed
任何人都有解決方案或解決方法?
快速復制粘貼方式
sudo sh -c 'echo zend_extension=$(find /usr/lib/php/extensions -name "xdebug.so") >> $(php -qr "echo php_ini_loaded_file();") && apachectl restart'
此命令執行以下操作:
與Sierra,El Capitan和Yosemite兼容,帶有Bunleled apache,但未經MAMP和XAMPP測試。
在啟動命令之前,請確保已安裝Xcode命令行工具: xcode-select --install
不知道使用pecl
。 在沒有pecl
情況下,在安裝OS X之后獲取Xdebug非常簡單。 你有兩個簡單的選擇:
使用以下版本:
/usr/lib/php/extensions/no-debug-non-zts-2010052/xdebug.so
建立你自己的:
確保您擁有Xcode CLI工具: xcode-select --install
將提示您安裝CLI工具。 安裝CLI工具后, /usr/include/php
應該有東西。
轉到http://xdebug.org/download.php並下載您想要的Xdebug版本的源代碼tarball。 例如: http : //xdebug.org/files/xdebug-2.2.3.tgz 。
將tarball解壓縮並cd
到它創建的目錄中。 在該目錄中,您將看到README
。 從這里開始:
$ phpize Configuring for: PHP Api Version: 20100412 Zend Module Api No: 20100525 Zend Extension Api No: 220100525 $ ./configure --enable-xdebug checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for a sed that does not truncate output... /usr/bin/sed [... output ...] $ make [... output ...]
您構建的xdebug.so
現在位於modules/xdebug.so
。 phpize
對於安裝XCode CLI工具至關重要,因為phpize
為您的PHP版本設置構建參數。
使用上面(1)或(2)中的xdebug.so
,您可以將此塊添加到php
或php-fpm
使用的php.ini
中:
[Xdebug]
zend_extension=<full_path_to_xdebug.so>
xdebug.remote_enable=1
xdebug.remote_host=<host running PHP (e.g. localhost)>
xdebug.remote_port=<port Xdebug tries to connect to on the host running PHP (default 9000)>
這里有兩個問題。 首先,您需要使用以下命令安裝Xcode命令行工具:
xcode-select --install
這意味着以前在/usr/include/php/
找不到的文件將可用。
下一步是按照Ares在答案中顯示的方式安裝autoconf
。
我會cd
到您的下載文件夾第一
cd ~/Downloads/
curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz
tar xzf autoconf-latest.tar.gz
cd autoconf-*
./configure --prefix=/usr/local
make
sudo make install
現在你可以運行pecl install
命令了
sudo pecl install xdebug
如果您使用的是Mac Yosemite 10.10,則上述答案均未解決問題。 請執行下列操作:
打開一個終端
執行find /usr/lib/php/extensions -name "xdebug.so"
以了解調試庫的路徑。
sudo nano /etc/php.ini
來打開並編輯php.ini文件 在php.ini中,最后添加以下行
[XDebug] zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so" xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000
(完成后,鍵入control+o
保存並control+x
關閉文件)
(不要忘記在第一個終端命令中獲取的內容中替換zend_extension中的值)
sudo apachectl restart
以加載新配置 對於任何面臨此問題的人,我必須從源代碼構建autoconf。 我從另一個StackOverflow問題中聽到了這個答案。
對於問題phpize錯誤,嘗試這將解決您的問題:sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include / usr /包括
我不得不brew install xdebug
並選擇我的PHP版本,它的工作brew install xdebug
! 例如,
brew install homebrew/php/php56-xdebug
對於PHP版本5.6變體。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.