您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Centos下PHP配置xdebug

2024/4/22 9:20:25发布42次查看
首先需要下载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
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.                                   |
|                                                                      |
|   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成功。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product