【发布时间】:2021-04-03 22:14:25
【问题描述】:
我有 vagrant + nginx + PHP + xdebug 的工作程序集。 PHP 版本为 7.0 时一切正常,但当我将 PHP 升级到 7.2 或 7.4 时,Xdebug 停止工作。 Xdebug 安装了最新版本(3.0.1)。
Vagrantfile(部分):
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 配置:
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 配置:
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
这些配置适用于 php7.0-fpm,但不适用于 php7.2-fpm 或 php7.4-fpm。问题出在哪里?
【问题讨论】: