During development, I used XDebug for local debugging, but recently I joined some projects and the environment was too complicated. it was really too troublesome to build a local development environment, so how can we use xdebug for remote debugging? Next, I will use XDebug for local debugging during the development of phpxdebug, but recently I have joined some projects, and the environment is too complex, it is too troublesome to build a local development environment. how can we use xdebug for remote debugging?
Here I use a virtual machine to build a simulated environment to illustrate the experiment:
1. Virtual Machine IP address: 192.168.174.130, which is used to build a lampp environment
2. Physical Machine IP address: 192.168.174.1, which is the IDE development environment.
First, I installed a lampp in the virtual machine and added a vhosts, as shown below:
vim /opt/lampp/etc/extra/httpd-vhosts.conf
ServerAdmin webmaster@dummy-host.example.com DocumentRoot "/data/web"
Options All AllowOverride All Require all granted
ServerName www.test.com ErrorLog "test-error_log" CustomLog "test-access_log" common
In order to set a domain name for vhosts, you need to modify the/etc/hosts of the physical machine before accessing it:
192.168.174.130 www.test.com
In the key step, we need to set php. ini in the virtual machine to support xdebug remote debugging. the following code is added:
vim /opt/lampp/etc/php.inizend_extension="/opt/lampp/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so"[xdebug]xdebug.default_enable=1xdebug.remote_enable=1xdebug.remote_handler=dbgpxdebug.remote_host=192.168.174.130xdebug.remote_port=9000xdebug.remote_connect_back=1xdebug.remote_autostart=1
The two most critical settings are xdebug. remote_host and xdebug. remote_connect_back. remote_host must be set to the server ip address, and remote_connect_back must be set to 1 or on
Now, the server is set up. next we will set the ide. forgive me for being an ide tool party. I use Intellij IDEA, and PHPStorm settings are the same.
First, set the project's server
Enter the address of the VM server that can be accessed normally in the Host field. the previously set virtual domain name is www.test.com, so this is also written in my figure.
The most critical setting is to check the path ING and write the file to be debugged into the path on the server. for example, I need to debug. php, and the web Directory we set on the VM server is/data/web/, then the ing path should be/data/web/. php.
After all the settings are complete, you can start the process like local debugging.
OK, there is no technical content, but I hope to help my friends who need it, pay attention to the IP address in the article, modify the address of your own server.
The above content will share with you the knowledge about remote PHP debugging XDEBUG. I hope you will like it.