linux 下 eclipse+XAMPP+pdt+xdebug

来源:互联网 发布:mysql默认链接地址 编辑:程序博客网 时间:2024/06/05 00:51

一.XAMPP

1.下载

http://www.apachefriends.org/en/xampp.html

2.安装

将下载的安装包解压到/opt下面,解压后的文件夹应该是/opt/lampp

运行lampp,进入/opt/lampp

问题:

a.出现错误error while loading shared libraries: libexpat.so.0: cannot enable executable stack as shared object requires: Permission denied

解决方法:

 

b.出现错误:Eror 1! Couldn't start Apache!

sudo netstat -na|grep 80

看80端口是否被占用,如果占用则改/opt/lampp/etc/httpd.conf中的监听端口即可,另外也有可能是防火墙把端口屏弊了,设置一下防火墙即可。

二、pdt-eclipse

1.下载eclipse pdt all-in-ones

http://www.eclipse.org/pdt/downloads/

2.安装

把下载后的压缩文件解压到/usr/local/eclipse_php

(注:这个all-in-ones的意思就是下来就能用的意思,所以要是你以前安装了其它的eclipse而又不想分开用的话,最好是下载插件包)

三、xdebug

http://code.activestate.com/komodo/remotedebugging/

下载后解压,找到合适版本的xdebug.so并将其复制到/opt/lampp/lib/php/extensions/中。然后修改/opt/lampp/etc/php.ini文件,在其最后加上

四、设置eclipse

打开Eclipse,在里面设定xdebug,
window->preferences->PHP->Debug,
PHP Debugger 选择 Xdebug
Server 选择 php Default Web Server,
phpExecutalbe 点进去之后按Add, 在Executable Path按Browse,选择/opt/lampp/bin/php-5.2.8 ,php ini文件路径在/opt/lampp/etc/php.ini ,名字嘛,随便给个就好,叫php吧,php debuger选择XDebug ,点ok

同样是在preferences里,点general,web browser ,点new ,指定下外部的Firefox浏览器地址:/usr/bin/firefox
下面添加一个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://localhost/first/first.php ,页面内容是:This is standard HTML.  想试试debug也一样,debug as PHP Web Page ,此时会提醒你是否切换到debug视角,点yes ,进入debug模式,用过别的IDE的应该很熟悉。想再换回PHP编辑视角,点右上角的PHP 图标的perspective就回来了。

注:经本人测试,只有XAPP和Eclipse搭配才能进行断点调试,如果是自己搭建的lamp系统,好像eclipse不能在断点处停止。

参考:
http://unixfans.blogbus.com/logs/34375330.html
http://www.apachefriends.org/f/viewtopic.php?t=4661
http://www.apachefriends.org/f/viewtopic.php?f=17&t=43928&view=previous