简体   繁体   English

如何使用 Visual Studio 19 调试在 azure Ubuntu VM 上运行的 php 应用程序

[英]How to use visual studio 19 to debug a php app running on an azure Ubuntu VM

I've configured the virtual machine, installed apache2, php, MySQL and xdebug.我已经配置了虚拟机,安装了 apache2、php、MySQL 和 xdebug。 The website works and I've configured VS but nothing happens when I debug the project in VS.该网站可以运行并且我已经配置了 VS,但是在 VS 中调试项目时没有任何反应。 Note I have to use a VM because there is some trickery that is being done with open VPN.注意我必须使用虚拟机,因为开放 VPN 正在完成一些技巧。

I am no expert with PHP as I come from the ASP.NET world and I have never used Xdebug before.我不是 PHP 专家,因为我来自 ASP.NET 世界,而且我以前从未使用过 Xdebug。

I've been asked to add some additional information but the /etc/php/7.2/apache2/php.ini file is too large to add into this post.我被要求添加一些额外的信息,但 /etc/php/7.2/apache2/php.ini 文件太大而无法添加到这篇文章中。 If you want some more information please ask for a section and I will post it.如果您需要更多信息,请索取一个部分,我会发布它。

In the mods-available folder is an xdebug.ini file that contains:在 mods-available 文件夹中是一个 xdebug.ini 文件,其中包含:

zend_extension=xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9000 #if you want to change the port you can change 

I've also set up an inbound rule in Azure for the server to a allow port 9000.我还在 Azure 中为服务器设置了一个允许端口 9000 的入站规则。

When running VS I have set up the Server URL and specified Xdebug Port 9000.运行 VS 时,我设置了服务器 URL 并指定了 Xdebug 端口 9000。

DBGp proxy is not set.未设置 DBGp 代理。

Thank you谢谢

Tim蒂姆

I finally managed to get something to work.我终于设法得到一些工作。

I updated the xdebug.ini like this:我像这样更新了 xdebug.ini:

zend_extension=/usr/lib/php/20170718/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 86.180.220.70
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9000 #if you want to change the port you can change
xdebug.idekey = "php-vs"

And, crucially, opened the firewall on my machine for port 9000.而且,至关重要的是,在我的机器上为端口 9000 打开了防火墙。

Now I can't seem to set any break points in php that actually hit.现在我似乎无法在实际命中的 php 中设置任何断点。

I'm assuming this has something to do with path mapping - plenty of stuff on google for Code but little if nothing for Visual Studio...我假设这与路径映射有关 - 谷歌上有很多关于代码的东西,但对于 Visual Studio 几乎没有...

I have to say the documentation for doing things like this is SHOCKINGLY bad.我不得不说做这样的事情的文档非常糟糕。 Most examples are for a Windows php.ini file, not for Linux.大多数示例适用于 Windows php.ini 文件,而不适用于 Linux。 If your a seasoned php programmer your probably used to it but for a newbie like me its an absolute minefield.如果您是一位经验丰富的 php 程序员,您可能已经习惯了它,但对于像我这样的新手来说,它绝对是一个雷区。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Visual Studio Code中使用Xdebug调试Ubuntu中的Xampp PHP脚本 - How to use Xdebug in Visual Studio Code to debug PHP Scripts in Ubuntu for Xampp 如何将两个域名绑定到在同一Azure Ubuntu VM中运行的两个不同的网站(php和nodejs)? - How to bind two domain names to two different websites(php and nodejs) running in same Azure Ubuntu VM? 如何使用Visual Studio在Windows上调试PHP 5运行时? - How to debug the PHP 5 runtime on Windows with Visual Studio? 如何在 Visual Studio Code 中调试 PHP? - How to debug PHP in Visual Studio Code? 如何在 Visual Studio 中使用 PHP - How to use PHP with Visual Studio 如何在不使用 XAMPP 或 WAMP 服务器的情况下在 Visual Studio Code 上调试 PHP Laravel - How can I debug PHP Laravel on Visual Studio Code without use XAMPP or WAMP server 用于 Visual Studio 的 PHP 工具。 如何调试 AJAX 请求? - PHP Tools for Visual Studio. How to debug AJAX requests? 如何在 Visual Studio Code (VSCode) 上运行或调试 php - How to run or debug php on Visual Studio Code (VSCode) 如何使用 Visual Studio Code 调试 PHP 页面中的 JS? - How to debug JS in PHP page with Visual Studio Code? 如何使用 php 5.6 调试项目。 在 Visual Studio 代码中? - How to debug project with php 5.6. in Visual Studio Code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM