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 192.168.2.0/255.255.255.0, and the gateway is 192.168.2.2.
The network segment of the windows host machine is 192.168.1.0/255.255.255.0.
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 192.168.2.1. Then the problem arises. The ip addresses of all requests obtained under the virtual machine are 192.168.2.1, 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 192.168.2.1, 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 192.168.2.1 to the host machine IP address 192.168.1.105.
We use root to configure the following iptabless rules:
Iptables-t nat-a output-p tcp-d 192.168.2.1 -- dport 19000-j DNAT -- to 192.168.1.105: 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.