我使用brew install php
在Homebrew中安装了PHP。
php -v
为我提供了:
PHP 8.0.9 (cli) (built: Jul 29 2021 17:21:21) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.9, Copyright (c) Zend Technologies
with Zend OPcache v8.0.9, Copyright (c), by Zend Technologies
所以PHP安装成功了,并且还作为一个服务与brew services start php
一起运行。
为了安装xdebug,我使用了命令pecl install xdebug
,它看起来工作正常,但在最后我得到了这样的消息:
Build process completed successfully
Installing '/usr/local/Cellar/php/8.0.9/pecl/20200930/xdebug.so'
Warning: mkdir(): File exists in System.php on line 294
PHP Warning: mkdir(): File exists in /usr/local/Cellar/php/8.0.9/share/php/pear/System.php on line 294
Warning: mkdir(): File exists in /usr/local/Cellar/php/8.0.9/share/php/pear/System.php on line 294
ERROR: failed to mkdir /usr/local/Cellar/php/8.0.9/pecl/20200930
安装文档xdebug.org中的安装说明没有帮助。我尝试在php目录中创建一个目录99-xdebug.ini (它不是由安装命令创建的),并编辑php.ini文件以添加zend_extension=xdebug。但是在重启网络服务器和php服务后,这并不起作用,xdebug (php -v
)仍然没有显示php。
我使用的是Macbook 13 2017,没有Touch Bar和Big Sur。
编辑:我从导演中删除了pecl,现在安装工作正常。但是现在我在使用php-v
时遇到了以下问题
PHP Warning: Failed loading Zend extension 'xdebug' (tried: /usr/local/lib/php/pecl/20200930/xdebug (dlopen(/usr/local/lib/php/pecl/20200930/xdebug, 9): image not found), /usr/local/lib/php/pecl/20200930/xdebug.so (dlopen(/usr/local/lib/php/pecl/20200930/xdebug.so, 9): image not found)) in Unknown on line 0
Warning: Failed loading Zend extension 'xdebug' (tried: /usr/local/lib/php/pecl/20200930/xdebug (dlopen(/usr/local/lib/php/pecl/20200930/xdebug, 9): image not found), /usr/local/lib/php/pecl/20200930/xdebug.so (dlopen(/usr/local/lib/php/pecl/20200930/xdebug.so, 9): image not found)) in Unknown on line 0
PHP 8.0.9 (cli) (built: Jul 29 2021 17:21:21) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.9, Copyright (c) Zend Technologies
with Zend OPcache v8.0.9, Copyright (c), by Zend Technologies
发布于 2021-08-26 20:54:28
我通过卸载xdebug和php解决了这个问题。我确保没有留下任何conf文件或目录。我使用rm -rf删除了包含php.ini的php目录。
而不是我刚刚用brew重装php。在安装xdebug之前,我检查了pecl文件是否存在,这个文件首先导致了问题(确保它不存在),然后使用pecl重新安装xdebug。并且在安装xdebug时没有出现错误。php -v给了我想要的完美响应。我猜问题首先是pecl文件干扰了xdebug的干净安装,并导致了所有这些问题。
PHP 8.0.10 (cli) (built: Aug 26 2021 15:36:17) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.10, Copyright (c) Zend Technologies
with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans
with Zend OPcache v8.0.10, Copyright (c), by Zend Technologies
https://stackoverflow.com/questions/68944020
复制相似问题