问题
I have the working assembly of vagrant + nginx + PHP + xdebug. Everything is ok while the PHP version is 7.0, but when I upgrade PHP to 7.2 or 7.4 Xdebug stop works. Xdebug installed the latest version (3.0.1).
Vagrantfile (part):
sudo add-apt-repository -y ppa:ondrej/php
sudo add-apt-repository -y ppa:ondrej/nginx
sudo apt-get update
sudo apt-get install -y nginx
sudo apt-get install -y php7.0-fpm php7.0-xdebug
sudo service php7.0-fpm stop
sudo cp /vagrant/.provision/xdebug.ini /etc/php/7.0/mods-available/xdebug.ini
sudo service php7.0-fpm start
sudo service nginx start
sudo cp /vagrant/.provision/project.local /etc/nginx/sites-available/project.local
sudo chmod 644 /etc/nginx/sites-available/project.local
sudo ln -s /etc/nginx/sites-available/project.local /etc/nginx/sites-enabled/project.local
sudo service nginx restart
Nginx config:
server {
listen 80;
index index.php;
server_name project.local www.project.local;
root /var/www/project.local;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
index index.php;
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
Xdebug config:
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
xdebug.remote_host=192.168.33.11
xdebug.remote_port=9001
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_cookie_expire_time = 36000
xdebug.remote_log=/var/www/project.local/.xdebug/xdebug.log
xdebug.idekey=vagrant
These configs working on php7.0-fpm, but not working on php7.2-fpm or php7.4-fpm. Where can be the problem?
回答1:
Xdebug installed the latest version (3.0.1).
You are using Xdebug v3 but keep using Xdebug v2 config parameters. You need to go through Upgrading from Xdebug 2 to 3 Guide and adjust your settings (mostly just change the parameter names).
Xdebug v3 uses different config params than Xdebug v2. From what I see 9 out of 10 "xdebug." params from your current php.ini do nothing in Xdebug v3 (if you would check Xdebug section of the phpinfo()
output you would see that).
For Xdebug 3 it should be something like this (based on your original config):
zend_extension=xdebug.so
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.discover_client_host = true
xdebug.client_host = 192.168.33.11
xdebug.client_port = 9001
xdebug.log = /var/www/project.local/.xdebug/xdebug.log
xdebug.idekey = vagrant
来源:https://stackoverflow.com/questions/65455619/why-does-assembly-of-vagrant-and-xdebug-not-works-on-latest-versions-of-php