可以xdebug官方网站下载与php对应的版本。目前支持php5的最高版本为xdebug2.5.5。支持php7的最高稳定版本为2.7.2。
正常安装lnmp后,本文中默认选择的php版本为7.1。随后进入lnmp安装源目录执行 ./install.sh mphp 安装php5.6。
为php7.1安装xdebug2.7.2:
tar -zxvf xdebug-2.7.2.tgz cd xdebug-2.7.2 /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config sudo make && sudo make install
为php5.6 安装xdebug2.5.5:
tar -zxvf xdebug-2.5.5.tgz cd xdebug-2.5.5 /usr/local/php5.6/bin/phpize ./configure --with-php-config=/usr/local/php5.6/bin/php-config sudo make && sudo make install
lnmp安装多版本php后会生成/usr/local/nginx/conf/enable-php5.6.conf和/etc/init.d/php-fpm5.6等文件。
nginx虚拟主机配置可参考下面的文本:
server
{
listen 80;
#listen [::]:80 default_server ipv6only=on;
server_name test.srv;
index index.html index.htm index.php;
root /home/wwwroot/test;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php5.6.conf;
access_log /home/wwwlogs/access.log;
}
在php.ini中配置xdebug参考如下:
[XDebug] xdebug.profiler_output_dir="/tmp/xdebug" xdebug.trace_output_dir="/tmp/xdebug" xdebug.profiler_append = 0 xdebug.profiler_enable = 1 xdebug.profiler_enable_trigger = 0 xdebug.profiler_output_name = "cache.out.%t-%s" xdebug.remote_enable = 1 xdebug.remote_mode = "req" xdebug.remote_handler = "dbgp" xdebug.remote_host = "192.168.112.1" xdebug.remote_port = 9001 zend_extension="/usr/local/php5.6/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so"