Precautions for using xdebug in a virtual machine environment in php

Source: Internet
Author: User
Tags iptables virtual environment zend

Symptom: zend studio xdebug 57% waiting for xdebug session

The development environment of the author is usually a windows host machine + vmare Linux virtual machine. The linux samba function shares the directories under the virtual machine to windows for disk ING, such a development environment can quickly implement a complete Linux code debugging environment in windows.

When xdebug is installed for php to debug code under the virtual machine today, xdebug is configured according to the online steps, because the network of my virtual machine environment is NAT.

The network segment of the linux virtual machine is, and the gateway is

The network segment of the windows host machine is

When a windows browser accesses the http service under the virtual machine, it is forwarded through the nat virtual network card of vmare. The p bound to this network card is Then the problem arises. The ip addresses of all requests obtained under the virtual machine are, and the network is blocked when the request for xdebug is obtained and the information is forwarded to zend studio. The xdebug port I set is 19000, as shown in the following figure:


We can see from the figure that our request is sent to Port 19000 of, but this is stuck because the syn_sent process has no network connection and php cannot connect to zend studio on the windows host. As long as the problem is located, the fastest solution is to enable iptables port forwarding and forward all data sent to Port 19000 of to the host machine IP address

We use root to configure the following iptabless rules:

Iptables-t nat-a output-p tcp-d -- dport 19000-j DNAT -- to 19000

In this way, zend studio can easily receive xdebug debugging data from php.

The virtual environment in the NAT network mode is quite painful. If you switch to the bridge mode to make the host machine and the virtual machine have the same network segment, the problem can be solved.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.