zoukankan      html  css  js  c++  java
  • Debian(Linux)+XAMPP(LAMPP)+Zend Studio + PHP +XDebug 完整的开发环境配置方法。

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

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

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

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

    2,安装Zend Studio

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

    第一次运行Zend Studio时,需要指定workspace的地址,如果你只是为了开发php,那么可以把工作区地址指定到:/opt/lampp/htdocs ,因为这里是XAMPP中apache的docs地址,添加的php文件可以直接在浏览器中运行。但坏处是删除文件时要小心,不然把XAMPP中htdocs文件夹里原有的文件删除了。也可以不这样做,将工作区用ln命令链接到htdocs文件夹下即可。

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

    3,下面开始装Xdebug。

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

      "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

  • 相关阅读:
    Codeforces Round #649 (Div. 2) D. Ehab's Last Corollary
    Educational Codeforces Round 89 (Rated for Div. 2) E. Two Arrays
    Educational Codeforces Round 89 (Rated for Div. 2) D. Two Divisors
    Codeforces Round #647 (Div. 2) E. Johnny and Grandmaster
    Codeforces Round #647 (Div. 2) F. Johnny and Megan's Necklace
    Codeforces Round #648 (Div. 2) G. Secure Password
    Codeforces Round #646 (Div. 2) F. Rotating Substrings
    C++STL常见用法
    各类学习慕课(不定期更新
    高阶等差数列
  • 原文地址:https://www.cnblogs.com/kungfupanda/p/1887812.html
Copyright © 2011-2022 走看看