I use xdebug in the development of the local debugging, but recently joined some projects, the environment is too complex, to build a local development environment is really too much trouble, so how do we use Xdebug to debug remotely?
I use a virtual machine to build a simulation environment to experiment with the description:
1. Virtual machine ip:192.168.174.130, virtual machine is used to build LAMPP environment
2. Entity 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 webmaster@dummy-host.example.com
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
Here to facilitate the setting of a domain name for vhosts, this need to modify the/etc/hosts of the entity to access:
192.168.174.130 www.test.com
The key step is to set up the php.ini in the virtual machine to support Xdebug remote debugging, adding the following code:
Vim/opt/lampp/etc/php.ini
zend_extension= "/opt/lampp/lib/php/extensions/no-debug-non-zts-20131226/ Xdebug.so "
[Xdebug]
xdebug.default_enable=1
xdebug.remote_enable=1
XDEBUG.REMOTE_HANDLER=DBGP
xdebug.remote_host=192.168.174.130
xdebug.remote_port=9000
xdebug.remote_connect_back=1
The two most critical settings xdebug.remote_host and xdebug.remote_connect_back,remote_host to be set to server Ip,remote_connect_back to be set to 1 or on
Here, the server is set up, next we set the IDE, please forgive me for being an IDE tool party. I use the IntelliJ idea, and the Phpstorm setting is the same.
First set up the project's server
In the host to fill in, the normal access to the virtual machine server address, we have previously set the virtual domain name is www.test.com, so I also write this picture.
The most important setting is to hook up this path mapping, and then write the files that need to be debugged on the server path, such as I need to debug a.php here, and the web directory we set up on the virtual machine server is/data/web/, then the path it maps should be/data/web/ It's a.php.
After everything is set up, you can start as a local debugging.
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.
The above content to share the PHP remote debugging Xdebug related knowledge, hope everybody likes.