xdebug with XAMPP on Mac OS X

源blog地址http://blog.laaz.org/tech/2010/08/27/xdebug-with-xampp-on-mac-os-x/

I just upgraded my XAMPP to latest release and found myself trapped with no memory of how to install xdebug on a Mac with XAMPP.

0. Install Xcode and autoconf

Thanks to Cedric Talbot for commenting and pointing out that I had not noticed I had all the needed developer tools already in place from all the development I do on my Mac. According to Cedric’s experience, you’ll need to have at least Autoconf installed via MacPorts or Homebrew and that in turn will require you to install Xcode. Once you have Xcode installed, go to Xcode prefs -> Downloads pane and install ‘Xcode command line tools’ and when that is done, open terminal and enter:

sudo xcode-select -switch /Applications/Xcode.app

This will set the folder where the Xcode is installed so that all the command line tools find it. Now continue with Macports or Homebrew to install autoconf.

1. Install XAMPP Developer package

Building xdebug requires you to have php headers, so download and install corresponding developer package for XAMPP.

2. Download xdebug

Download xdebug source from here or checkout from GIT:

git clone git://github.com/derickr/xdebug.git
cd xdebug

3. PHPIZE

Run phpize

/Applications/XAMPP/xamppfiles/bin/phpize

4. Configure xdebug

Recent XAMPP (mine was 1.8.3-2) are built 64bit and so the configure is rather simple:

./configure --enable-xdebug --with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config

If your XAMPP is built for i386 (32-bit) architecture, you have to modify default build flags, which otherwise would build for x86_64 (64-bit):

./configure --enable-xdebug --with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config CFLAGS="-arch i386 $CFLAGS" CCFLAGS="-arch i386 $CCFLAGS" CXXFLAGS="-arch i386 $CXXFLAGS" LDFLAGS="-arch i386 $LDFLAGS"

edit: configure command updated to append variables instead of prepending them (thanks Sequan).

edit2: Alternatively, as suggested by Junaid below, on a Lion you could use the following command (haven’t tried it myself), which is essentially the same, only providing architecture as direct argument to compiler instead of setting it in FLAGS:

./configure --enable-xdebug CC="gcc -arch i386" CXX="g++ -arch i386"

edit3: If, for some unknown reason, you still don’t get the correct architecture, you can manually edit the Makefile and fix the compile flags yourself. The screenshot shows the only 3 differences in resulting Makefile if I ran the ./configure command without (64-bit, left) and with (32-bit, right) the FLAGS settings:

Just open the Makefile in your favorite text editor and adjust the flags directly.

5. Make

make

When the compilation finishes, you can verify that the module was built 32-bit, by running:

> lipo -info modules/xdebug.so
Non-fat file: modules/xdebug.so is architecture: i386

The architecture should be reported as i386. When you get x86_64, then your configure didn’t succeed in setting the architecture and you should revert to step 4.

6. Copy files

Copy the files to PHP extensions directory. You might need to adjust the path for your XAMPP and PHP version:

sudo cp modules/* /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/

7. Configure PHP.ini

Final step is to configure php.ini file. So open /Applications/XAMPP/etc/php.ini with your favorite editor and add the lines to the bottom of it:

[xdebug]
zend_extension=/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000

EDIT: As pointed out by strah below, if you’re going to use MacGDBp for debugging GUI, you need to add additional line to php.ini file:

xdebug.remote_autostart=1

So that debbugger is connected on every page load.

NOTE: this is not reccommended in production environments as it degrades performance! Now restart Apache and you should be good to go.

Be Sociable, Share!

时间: 2024-12-18 14:45:25

xdebug with XAMPP on Mac OS X的相关文章

让PHP跑在Mac OS X中

[合肥开源IT教育][合肥网页设计培训][开源IT教育][合肥PHP培训][合肥开源IT教育培训][合肥开源IT培训] MacBook入手了,配置工作环境,首先得让Mac OS支持PHP.不管你是采用集成的开发环境,比如XAMPP for Mac OS X,还是采用Mac OS中自带的Apache和PHP,甚至自己重新编译安装,减少麻烦的第一步就是启用root用户. 本文采用的方式是使用Mac OS X 10.5.6自带的Apache和PHP,安装MySQL的dmg版本,以下操作非特殊说明均以r

mac os利用xampp实现apache下的cgi

折腾了两天终于把问题解决了,mac os是10.10.3..够新了吧 系统原生的apache配置cgi老是配不好,突然发现xampp也有macos版的,准备下下来试试. 安装完成后,打开apache服务 新建一个文件test.py 1 #!/usr/bin/python 2 print "Content-type: text/html" 3 print 4 print "<html><head>" 5 print "" 6

在Mac OS X中配置Apache + PHP + MySQL

在Mac OS X中配置Apache + PHP + MySQL Mac OS X 内置Apache 和 PHP,使用起来非常方便.本文以Mac OS X 10.6.3和为例.主要内容包括: 启动Apache 运行PHP 安装MySQL 使用phpMyAdmin 配置PHP的MCrypt扩展库 设置虚拟主机 启动Apache 有两种方法: 打开“系统设置偏好(System Preferences)” -> “共享(Sharing)” -> “Web共享(Web Sharing)”. 打开“终端

在Mac OS X中配置Apache + PHP + MySQL 很详细

这是一篇超级详细的配置mac os下面php+mysql+apache的文章.非常详细我的大部分配置就是参考上面的内容的,比如,PHP不能连接数据库,就是改一下默认的php.ini中pdo_mysql.default_socket[因为现在都用PDO了嘛.不用mysql的连接库了]因为我是用navicat的,所以对phpmyadmin那一块的配置就不太关心了.不过MCrypt的安装可以参考.原文来自:在Mac OS X中配置Apache + PHP + MySQL内容如下: Mac OS X 内

在Mac OS X中配置Apache

启动Apache 有两种方法: 打开“系统设置偏好(System Preferences)” -> “共享(Sharing)” -> “Web共享(Web Sharing)” 打开“终端(terminal)”,然后 运行“sudo apachectl start”,再输入帐号密码,这样Apache就运行了. 运行“sudo apachectl -v”,你会看到Mac OS X 10.6.3中的Apache版本号: Server version: Apache/2.2.14 (Unix) Ser

笔记:MAC OS X下配置PHP开发、调试环境

操作系统:MAC OS X 工具:MAMP.PhpStorm.xdebug.chrome 1.下载MAMP 2.安装比较简单,安装完成后,应用程序中会增加如下4个应用 MacGDBp是PHP调试器,使用的是xdebug 若要使用此调试器,需要在php.ini中配置: [xdebug] zend_extension="/Applications/MAMP/bin/php/php5.5.10/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so

方便mac os 10.9系统中phpstorm配置php运行环境

自己安装php,不用mac安装,这样就有php开发环境了. 安装很简单,直接运行一个命令, 需要几分钟,请慢慢等待. curl -s http://php-osx.liip.ch/install.sh | bash -s 5.5 (注5.5是php版本可以是5.6等等) 新安装的php目录是/usr/local/php5/bin,接下来在PhpStorm中设置新安装的php解释器: PhpStorm->Preferences->PHP 会来到解释器设置页 设置我们安装的php解释器:/usr/

Qt在Mac OS X下的编程环境搭建(配置Qt库和编译器,有图,很清楚)

尊重作者,支持原创,如需转载,请附上原地址:http://blog.csdn.net/libaineu2004/article/details/46234079 在Mac OS X下使用Qt开发,需要配置Qt库和编译器.编译器只能使用苹果公司自主研发的Clang.1.分别下载并安装XCode和Command Line Tools(必须安装),安装完毕后,Clang就有了. https://developer.apple.com/downloads/ 2.下载Qt并默认安装 http://down

Mac OS X 10.10上以命令行模式使用GLWF3

GLWF3的介绍请移步其官网:http://www.glfw.org/docs/latest/index.html 按照其官网上的安装介绍,用cmake从源码安装GLWF3 Building Applications with GLWF3可以见http://www.glfw.org/docs/latest/build.html#build_link_osx 但它给的用命令行模式在Mac OS X上使用的方法是不全的,会导致不少错误,比如: Undefined symbols for archit