The following is an introduction to PHPSTROM remote debugging from the phpstorm tutorial column. I hope it will be helpful to friends in need!
Install DVWA project
System environment
whippet@ubuntu:~/Desktop$ cat /etc/issue
Check whether the PHP environment has been installed
whippet@ubuntu:~/Desktop$ dpkg -l | grep php
Add PPA source
whippet@ubuntu:~/Desktop$ sudo add-apt-repository ppa:ondrej/php
Update system
whippet@ubuntu:~/Desktop$ sudo apt-get update
Install php 5.6
whippet@ubuntu:~/Desktop$ sudo apt-get install php5.6
Install apache and start
whippet@ubuntu:~/Desktop$ sudo apt install apache2
Install mysql and start
whippet@ubuntu:~/Desktop$ sudo apt-get install mysql-server
Install DVWA
whippet@ubuntu:~/Desktop$ cd /var/www/html/
Configure PHPSTROM debugging
Environmental conditions
Machine name | Operating system | ip information | Experimental environment |
---|---|---|---|
Virtual Machine | Ubuntu 20.04.2 | 192.168.176.171 | PHP 5.6.40 |
Local machine | Windows10 | 192.168.176.1 | phpstrom |
xdebug 配置
我们直接在 xdebug 的官网上寻找历史版本^[1]^ 全局搜索 php 5.6
我们可以看到相较于 windows 上种类繁多的二进制文件,linux 只提供了源码文件,需要自己进行编译,下载源码之后我们复制到虚拟机内部
whippet@ubuntu:~$ tar -xcvf xdebug-2.5.5.tgz
xdebug 被安装在 /usr/lib/php/20131226/
修改php.ini配置文件,在文件中追加以下内容
[Xdebug]
保存之后重启 apache 服务 sudo service apache2 restart 之后访问 phpinfo 发现xdebug 的信息已经显示出来了
至此 xdebug 的相关配置就 ok 啦,接下来我们对本地的 phpstrom 进行配置
PHPSTROM 配置
首先我们从虚拟机内,把已经安装好的项目代码打包再脱下来,这是因为,有一些项目在安装之后会对源代码进行一定的修改,为了不出现偏差我们就把安装好的代码给拖取下来。利用 PHPSTROM 打开这个项目,并配置相关参数信息
File -> Settings -> Languages & Frameworks -> PHP -> Debug
配置 Servers
此处要注意,需要直接指定到网站的目录位置
配置PHP Web Application
然后我们打开登录的 login.php ,在其中添加断点,并设置 PHPSTROM 的监听模块
浏览网站页面,同时打开浏览器的调试插件
我们可以看到已经跳到我们断点的位置
至此调试的基本过程已经完成,以下的步骤属于可做可不做,本着学习的想法,我还是把添加上吧
SSH 配置
先大致描写一下为什么要进行这个操作,就是为了方便对 php 文件的修改,有时候我们想对 php 文件进行修改,但是在本地修改之后,并不会影响远端服务器上的文件,经过这样的配置之后,本地文件修改之后,远端服务器上的文件也会同步修改。
首先,我们安装好的 Ubuntu 虚拟机上是并不存在 SSH 的,所以我们需要先将 Ubuntu 上的 SSH 进行配置。
# 安装 openssh 服务
验证一下,发现可以登录成功
打开 PHPSTROM
添加一个 sftp 协议
选择 ubuntu 上 php 的路径位置
至此已经基本配置完成,我们来进行一下验证
File -> Settings -> Languages & Frameworks -> PHP -> Debug
配置完成,我们修改一个文件进行验证一下
The above is the detailed content of Detailed explanation about remote debugging of PHPSTROM. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Linux new version
SublimeText3 Linux latest version