一、安装了 xdebug
php -m | grep 'xdebug'
如果没有安装就执行
-1.下载xdebug
wget https://xdebug.org/files/xdebug-2.7.0.tgz
-2.解压
tar -zxvf xdebug-2.7.0.tgz
cd xdebug-2.7.0
-3.运行phpize,通过phpize可以 生成 configure 文件,动态的添加php扩展
phpize
-4. 配置,--with-php-config=运行PHP的版本
./configure --enable-xdebug --with-php-config=/usr/bin/php7.2
-5.编译&生成
make && make install
编译&&生成后,屏幕上会有输出
installing shared extensions: /usr/lib/php/20170718/
+----------------------------------------------------------------------+
| |
| INSTALLATION INSTRUCTIONS |
| ========================= |
| |
| See http://xdebug.org/install.php#configure-php for instructions |
| on how to enable Xdebug for PHP. |
| |
| Documentation is available online as well: |
| - A list of all settings: http://xdebug.org/docs-settings.php |
| - A list of all functions: http://xdebug.org/docs-functions.php |
| - Profiling instructions: http://xdebug.org/docs-profiling2.php |
| - Remote debugging: http://xdebug.org/docs-debugger.php |
| |
| |
| NOTE: Please disregard the message |
| You should add "extension=xdebug.so" to php.ini |
| that is emitted by the PECL installer. This does not work for |
| Xdebug. |
| |
+----------------------------------------------------------------------+
编译安装完成后会有一个 modules文件夹,该文件夹下有一个xdebug.so的文件,将此文件复制到对应PHP版本的扩展目录即可。当然,如果PHP已经设置了扩展目录地址,该文件就会自动复制到了扩展目录中,
如:我的扩展目录是 /usr/lib/php/20170718/ ,目录下面会生成一个 xdebug.so 的动态库文件
说明: /usr/lib/php/20170718/ 该目录是存放PHP扩展的目录,phpinfo()里看到 extension_dir 该属性的值。
二、PHP 配置文件添加配置
vim /usr/local/php/etc/php.ini - 添加 zend_extension=xdebug.so # 这里没有写绝对路径,是因为会到扩展目录中去找 xdebug.remote_enable = 1 xdebug.remote_connect_back = 1 xdebug.remote_port = 9900 xdebug.max_nesting_level = 512 - 保存退出
三、重启PHP
service php-fpm restart
四、查看
通过 phpinfo() 输出查看,或者 通过命令 php -m | grep 'xdebug'