Good day.

There is a machine (host machine) on which a virtual machine is installed. The virtual machine has CentOS 6 + apache + nginx: apache is running on port 8080, nginx on port 80.

host configuration (which I want to debug) apache:

<VirtualHost *:8080> ServerAdmin alex@troom.ru ServerName tests.local ServerAlias www.tests.local DocumentRoot /home/httpdocs/tests.local/www <Directory /home/httpdocs/tests.local/www> Options Indexes FollowSymLinks </Directory> ErrorLog /home/httpdocs/tests.local/log/apache_error_log CustomLog /home/httpdocs/tests.local/log/apache_access_log common </VirtualHost> 

host configuration (which I want to debug) nginx:

 server { listen 80; server_name tests.local www.tests.local; access_log /home/httpdocs/tests.local/log/nginx_access_log main; # Не кеширую статику #location ~* \.(jpg|jpeg|gif|png|ico|css|bmp|avi|flv|swf|js|doc|docx|rtf|pdf|xls|xlsx|rar|zip|tbz|7z|tgz|tar|gz|bz2|ppt|txt|mid|midi|wav|exe|ttf|eof|svg|woff)$ { # root /home/httpdocs/tests.local/www/; # access_log off; # expires 30d; # add_header Cache-Control public; #} location ~ /\.ht { deny all; } location / { proxy_pass http://127.0.0.1:8080/; proxy_redirect off; log_not_found off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Connection close; proxy_pass_header Content-Type; proxy_pass_header Content-Disposition; proxy_pass_header Content-Length; proxy_connect_timeout 60; proxy_send_timeout 90; proxy_read_timeout 90; } } 

xDebug, /etc/php.d/xdebug.ini settings:

 zend_extension=/usr/lib64/php/modules/xdebug.so 

and php.ini:

 [xdebug] xdebug.default_enable=on xdebug.remote_enable=on xdebug.remote_autostart=on xdebug.idekey="PHPSTORM" xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000 xdebug.remote_handler=dbgp xdebug.auto_trace=off xdebug.remote_log="/tmp/xdebug_log.log" xdebug.profiler_output_dir="/tmp" 

On the IDE PHPStorm host machine, xDebug settings: enter image description here enter image description here

Google Chrome has the xDebug helper extension installed.

When trying to debug nothing happens, the xDebug log is written:

 Log opened at 2015-11-02 12:05:34 I: Connecting to configured address/port: 127.0.0.1:9000. E: Could not connect to client. :-( Log closed at 2015-11-02 12:05:34 

I understand that the problem with nginx is most likely, but I don’t know what exactly is missing.

Please help me figure it out.

  • Thanks, really managed to figure it out. - Alexander

2 answers 2

 xdebug.remote_host=127.0.0.1 

You openly specify the host to which you want to connect (and this is localhost, ie, virtualka). You also need an external host, specify its IP address in the network to which the virtual machine belongs. The automatic connect back probably will not work anyway, because it will see the IP address of the proxying nginks (why do you need an apache at all - a separate question, you can safely throw it away).

  • >> (why do you need an Apache at all - a separate question, you can safely throw it away). Do you mean that it is better to use nginx + php-fpm, instead of nginx + apache? - Alexander
  • @ Alexander yes, the Apache is slow, and mod-php is not a particularly optimal thing - etki
  • And with .htaccess and such things will not be problems? ps: I'm just not very familiar with php-fpm. - Alexander
  • @Alexander, there is a slightly different situation, but believe me, .htaccess is not really needed and is a malicious thing (especially from the point of view of query optimization). In nginx, the config is maintained (most often) in one file per host, and after a while it becomes more convenient. The php-fpm connection itself usually takes up five lines - much less than the current proxy config. - etki

I can not yet comment. IP is local. Do you have a web server and browser on the same machine? If the web server is running inside a virtual machine and the browser is in the parent system, then their IP is different.