Debian(Linux)+XAMPP(LAMPP)+Zend Studio + PHP +XDebug 完整的开发环境配置方法。 转摘:http://www.cnblogs.com/kungfupa

经历了3天左右的挣扎,终于在Linux下将 php开发工具 Zend Studio 的 xdebug安装成功,分享以下:php

 

1,装XAMPP,安装方法连接以下:这里假设XAMPP的安装路径为:/opt/lampp,安装命令html

tar xvfz xampp-linux-1.4.7.tar.gz -C /opt (详细说明  http://unixfans.blogbus.com/logs/34373510.htmllinux

为避免和其余端口冲突,在httpd.conf文件中我将Listen配置为18000。之后用http://127.0.0.1:18000/  访问web

 

2,安装Zend Studioapache

下好后直接解压到你但愿的目录地址就算安装完成了,我这里假设安装在:/home/yourname/zend studio浏览器

第一次运行Zend Studio时,须要指定workspace的地址,若是你只是为了开发php,那么能够把工做区地址指定到:/opt/lampp/htdocs ,由于这里是XAMPP中apache的docs地址,添加的php文件能够直接在浏览器中运行。但坏处是删除文件时要当心,否则把XAMPP中htdocs文件夹里原有的文件删除了。也能够不这样作,将工做区用ln命令连接到htdocs文件夹下便可。服务器

以上两样的安装都比较简单,直接解压就搞定了。session

 

3,下面开始装Xdebug。app

我最开始按照xdebug官方的办法http://xdebug.org/docs/install 安装时,在Zend studio 中运行xdebug老是提示57% debug session 上,另外启动Apache时有以下提示:eclipse

  "Xdebug requires Zend Engine API version 220090626.
  The Zend Engine API version 220060519 which is installed, is outdated."

在这里下载已经编译好的Xdebug remote文件,注意你的版本和系统类型。

Link : http://aspn.activestate.com/ASPN/Downloads/Komodo/RemoteDebugging

下载好后j将xdebug.so文件,拷贝到你的LAMPP文件夹内,本文中路径以下:/opt/lampp/lib/php/extensions/

而后打开php.ini进行编辑,路径以下/opt/lampp/etc/php.ini

在此文件倒数第二行加入以下代码段,注意zend_extension和xdebug.profiler_output_dir要对应你的lampp的安装地址,我这里红色高亮。

[XDebug]
zend_extension="/opt/lampp/lib/php/extensions/xdebug.so"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=19000
xdebug.remote_handler=dbgp
xdebug.profiler_enable=1
xdebug.profiler_output_dir="/opt/lampp/tmp"

注意我这里输入的端口号是19000,不是默认的9000。9000端口极可能已被占用,并致使在Zend studio 中运行xdebug老是提示57% debug session 。

保存,退出。好,到此,xdebug安装完成,若是已经开启xampp了,请重启。

登陆http://127.0.0.1:18000/xampp ,点左边栏的phpinfo() ,查找“xdebug”关键字,若是有xdebug的详细信息,说明安装成功。

参考图:

 

这里有个小问题:官站说明文档中介绍:http://www.xdebug.org/docs/install#configure-php

add the following line to php.ini: zend_extension="/wherever/you/put/it/xdebug.so" (for non-threaded use of PHP, for example the CLI, CGI or Apache 1.3 module)

or: zend_extension_ts="/wherever/you/put/it/xdebug.so" (for threaded usage of PHP, for example the Apache 2 work MPM or the the ISAPI module).

虽然个人XAMPP中的apache版本是2.2.11,可是使用zend_extension_ts语句是没法加载xdebug的,请读者自行测试,若是zend_extension_ts不能加载,那么和我同样请用zend_extension。

 

4,  打开Zend studio,在里面设定xdebug,

window->preferences->PHP->Debug,
PHP Debugger 选择 Xdebug 注意个人xdebug的端口仍然是19000。
 参考图:
 
5, PHP Server 选择 Default Web Server,
参考图:
 
注意:须要配置成和XAMPP 的Apache IP、port 都一致,我将其配置为 http://127.0.0.1:18000/ 
从此在用xdebug调试php文件时,会显示一个URL 地址,前面的服务器路径是改不了的,就是在php server中配置的 http://127.0.0.1:18000/ 
若是在debug->debug configuration中能够设置每一个文件的debug信息,还能够单条删除,好比选中php Script->XX 文件,右键删除。
 
6, php Executalbe
点进去以后按Add, 在Executable Path按Browse,选择/opt/lampp/bin/php-5.2.8
php ini文件路径在/opt/lampp/etc/php.ini
php debuger选择XDebug ,点ok
参考图:
 
7, 测试:
下面添加一个php文件测试下是否成功。新建一个名为first的php project,在此project里新建一个php file,名字也叫first.php,点next,试用而已,因此选择new simple php file ,
填入下列代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <title>Basic PHP Page</title>
</head>
<body>
<p>This is standard HTML.</p>
</body>
</html>
保存,而后右击first.php, properties ,Run/Debug Settings ,点new ,选择php web server。
名称:first
server debugger :XDebug
PHP Server :Default。。。。。。
File一栏输入建立的PHP项目的相对路径,若是项目的绝对路径是/opt/lampp/htdocs/first/first.php,那么此栏只输入/first/first.php 
URL勾选auto generate就是。
点apply应用。
 
OK,右击first.php,run as PHP Web Page 看当作果。正常状况下应该是自动打开一个Firefox窗口,地址是 http://127.0.0.1:18000/first/first.php ,页面内容是:This is standard HTML.  想试试debug也同样,debug as PHP Web Page ,此时会提醒你是否切换到debug视角,点yes ,进入debug模式,用过别的IDE的应该很熟悉。想再换回PHP编辑视角,点右上角的PHP 图标的perspective就回来了。
 
8,关于web browser
在preferences里,点general,web browser ,点new  , 若是指定下外部的Firefox浏览器地址:/usr/bin/firefox
也能够安装Google browser,参考图:
----------------------
致谢:

如下做者和网站对本文完成有帮助:

http://unixfans.blogbus.com/logs/34375330.html

http://blog.sina.com.cn/s/blog_4dda073c0100bikk.html

http://www.ibm.com/developerworks/cn/linux/l-xampp/

http://www.latenightpc.com/blog/archives/2008/05/24/a-complete-lamp-development-environment-xampp-eclipse-pdt-and-xdebug

That which didn't kill me makes me stronger
相关文章
相关标签/搜索