Centos下PHP配置xdebug

php中文网
发布: 2016-06-20 12:38:33
原创
1155人浏览过

首先需要下载xdebug,我们可以 点此 下载xdebug-2.2.5.tgz,或者在 xdebug官网 下载相应的安装包。并且确定php的安装目录,假设php安装目录为/usr/local/php。

安装xdebug

对于xdebug可以独立于PHP进行编译安装,但是我们必须拥有执行phpize的权限,并且对于php-config也拥有相应的权限,此二者所在目录为

/usr/local/php/bin/phpize/usr/local/php/bin/php-config

接下来按照以下步骤安装xdebug

立即学习PHP免费学习笔记(深入)”;

1. # tar –zxvf xdebug-2.2.5.tg //解压源码包,但是需要注意的是没有必要把源码解压到PHP的源码包中,解压到独立的目录

2. # cd xdebug-2.2.5  //进入源码目录中

3. Xdebug]# /usr/local/php/bin/phpize //运行phpize命令,运行此命令以后会在源码目录中产生configure等文件

4. Xdebug]# ./configure –enable-xdebug –with-php-config=/usr/local/php/bin/php-config  //配置xdebug

5. Xdebug]# make && make install  //编译安装

在第四步中的选项 –with-php-config不能省略,如果我们省略了此选项,那么有可能会报如下错误

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking target system type... x86_64-unknown-linux-gnu

configure: error: Cannot find php-config. Please use --with-php-config=PATH

按照上述步骤安装,如果没有什么特殊情况的话安装会顺利的进行,最后出现如下结果表示安装成功

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/

+----------------------------------------------------------------------+

|                                                                      |

|   INSTALLATION INSTRUCTIONS                                          |

|   =========================                                          |

|                                                                      |

|   See http://xdebug.org/install.php#configure-php for instructions   |

|   on how to enable Xdebug for PHP.                                   |

|                                                                      |

琅琅配音
琅琅配音

全能AI配音神器

琅琅配音 208
查看详情 琅琅配音

|   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.                                                            |

|                                                                      |

+----------------------------------------------------------------------+

配置PHP 使其支持xdebug

按照上述最后的显示结果,说明xdebug已经安装成功,并且我们需要对php.ini文件进行配置,打开php.ini文件

# vim /usr/local/php/etc/php.ini   //打开php.ini文件

在文件中添加如下几行

zend_extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so

[Xdebug]

xdebug.remote_enable = 1   //开启远程调试

xdebug.remote_host = 192.168.18.228 //远程ip地址抑或是本机地址

xdebug.remote_port = 9000  //远程IDE服务器监听端口

xdebug.remote_handler=DBGP  //使用的协议

(除此之外,xdebug选项的详细解释请参考 xdebug所有设置说明 )

添加完以后,保存退出。如果PHP环境使用的是SAPIs方式,那我们需要重启Web服务器;如果使用的是FastCGI的方式那我们需要重启php-fpm。重启完以后,新建php脚本使用phpinfo()查看php的配置如下图

说明PHP配置xdebug成功。

PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号