I use xdebug in the development of the local debugging, but recently joined some projects, the environment is too complex, to build a development environment in the local is really too troublesome, then how can we use Xdebug to remote debugging?
Here I use a virtual machine to build a simulation environment to illustrate the experiment:
1. Virtual machine ip:192.168.174.130, virtual machine for building LAMPP environment
2. Physical machine ip:192.168.174.1, this is the IDE's development environment.
First I installed a lampp in the virtual machine, and added a vhosts, as follows:
vim/opt/lampp/etc/extra/httpd-vhosts.conf<VirtualHost*:80>ServerAdmin [email protected] documentroot "/data/web"<Directory"/data/web">Options All allowoverride all Require all granted</Directory>ServerName www.test.com errorlog "Test-error_log" Customlog " test-access_log" common</VirtualHost>
Here in order to facilitate the vhosts set a domain name, this need to modify the physical machine/etc/hosts before access:
192.168.174.130 www.test.com
The key step is to set the php.ini in the virtual machine to support Xdebug remote debugging, adding the following code:
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=1 Xdebug.remote_handler=dbgpxdebug.remote_host=192.168.174.130xdebug.remote_port=9000 xdebug.remote_connect_back=1xdebug.remote_autostart=1
The most critical of the two settings xdebug.remote_host and xdebug.remote_connect_back, remote_host to be set to the server Ip,remote_ Connect_back to be set to 1 or on
Here, the server is set up, next we set up the IDE, please forgive me is an IDE tool party. I use the IntelliJ idea, and the Phpstorm settings are the same.
First set up the project's server
In the host to fill in, to normal access to the address of the virtual machine server, we previously set the virtual domain name is www.test.com, so I also wrote this picture.
The most critical setting is to hook up the path map, and then write the file that needs to be debugged on the server, such as I need to debug a.php, and on the virtual machine server we set the Web directory is/data/web/, then it should be mapped to the path is/data/web/ It's a.php.
After everything has been set up, you can start with the local debugging as well.
OK, there is no technical content, but hope to help the needs of friends, pay attention to the article in the IP address, modify your own server address.
PHP-How do I use Xdebug to debug remotely?