我从源头根据https://xdebug.org/docs/install构建,因为pecl / pearl损坏了:
pecl install xdebug
downloading xdebug-2.8.0.tgz ...
Starting to download xdebug-2.8.0.tgz (238,122 bytes)
.................................................done: 238,122 bytes
PHP Fatal error: Cannot use result of built-in function in write context in /usr/share/php/Archive/Tar.php on line 639
构建后,lib位于/usr/lib/php/20180731/xdebug.so
中。我在/etc/php/7.3/apache2/php.ini
中添加了:
[opcache]
...
[xdebug]
zend_extension=~"/usr/lib/php/20180731/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
我重新启动了Apache:service apache2 restart
我用service apache2 status
检查过。
运行php -m
时显示
[Zend Modules]
Zend OPcache
但没有XDebug。php --version
的输出是:
PHP 7.3.12-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Nov 28 2019 07:36:56) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.12, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.12-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
root@HAL:/home/richard#
也没有XDebug。因此,现在我无法使XDebug与Visual Studio Code一起使用。有任何想法吗?非常感谢
和往常一样,这是一个愚蠢的用户(me)错误。我已经在Downloads文件夹中解压缩了XDebug的源代码。然后它是在〜/ Downloads / xdebug-2.8.0 / modules中构建的,我还在〜/ Downloads / xdebug-2.8.0 / .libs中找到了一个副本。
因此,首先我有一个指向我的主目录的路径,以〜开头。我发现* .so文件也已复制到/usr/lib/php/20180731/xdebug.so
,因为我在这里阅读了https://xdebug.org/docs/install
:
zend_extension="/usr/local/php/modules/xdebug.so"
我将其与自己的系统进行了比较。现在,这是一个大错误:编辑路径“ /usr/lib/php/20180731/xdebug.so”,我忘了删除开头的〜!!!
因此无法加载模块。一条错误消息说它找不到指定的路径/文件会很好,因为人类确实会犯错误。也许在某些日志文件中隐藏了这样的错误消息,我没有检查。至少警告阅读该日志文件会很棒。
删除此波浪号并重新启动服务器后,phpinfo显示XDebug模块已加载。
很抱歉浪费您的时间。我猜这里有很多问题是由于无知和愚蠢引起的,这表明我并非没有这些;-)
也许这对我来说是我自己解决的问题。
php.ini中的更新部分:
[xdebug]
zend_extension=/usr/lib/php/20180731/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_autostart = 1
一些是从The xdebug extension is not loaded那里取的
我希望这对其他人有帮助。
对于那些使用XDebug并因此可能正在建立网站的人:我写了一个这样的脚本(所有版权归托马斯·沃德所有:)
#!/bin/bash # https://askubuntu.com/questions/767504/permissions-problems-with-var-www-html-and-my-own-home-directory-for-a-website chgrp -R www-data /var/www/html find /var/www/html -type d -exec chmod g+rx {} + find /var/www/html -type f -exec chmod g+r {} + chmod -R o-rwx /var/www/html/ chown -R richard /var/www/html/ find /var/www/html -type d -exec chmod u+rwx {} + find /var/www/html -type f -exec chmod u+rw {} + # This sets the "set gid" bit for the group on the directories. # Files and folders created inside these directories will always have www-data as the group, # permitting the web server access find /var/www/html -type d -exec chmod g+s {} +
运行此命令后(通常仅运行一次),Visual Studio Code可以在/ var / www / html下写入文件>
现在,当Visual Code想要保存在Web项目中更改的文件时,不再提示您按OK并输入root密码。
当然,您需要填写自己的用户名。在您的情况下,路径/var/www/html
可能是/opt/lampp/htdocs
。
我希望这对其他人有帮助。