简体   繁体   中英

Building/Installing XDebug on Mac OSX with MAMP

I'm having a problem building / installing XDebug on Mac OSX with MAMP.

I searched online extensively so far and at the moment I am stuck on the part of XDebug "Installation Wizard" that tells me to "Run: phpize" on the source code I downloaded.

When i run phpize I get the following message:

new-host-2:xdebug-2.2.0 Dima$ phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:        
Zend Module Api No:     
Zend Extension Api No:  
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

If i do a which phpize i get:

new-host-2:xdebug-2.2.0 Dima$ which phpize
/usr/bin/phpize

This is not the version I want to use, I want to use the MAMP installed version of phpize I assume since i want to install XDebug on the MAMP version of PHP. This is puzzling because i added the MAMP specific PHP bin path to my.bash_profile already into the $PATH variable.

If i run echo $PATH i get:

new-host-2:xdebug-2.2.0 Dima$ echo $PATH
/opt/local/bin:/opt/local/sbin:/Applications/MAMP/bin/php/php5.4.3/bin:/Users/Dima/.rvm/gems/ruby-1.9.2-p290/bin:/Users/Dima/.rvm/gems/ruby-1.9.2-p290@global/bin:/Users/Dima/.rvm/rubies/ruby-1.9.2-p290/bin:/Users/Dima/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

The MAMP specific PHP path shows up ahead of '/usr/bin'. Next thing i tried is running the MAMP specific phpize providing it the entire path manually like so:

new-host-2:xdebug-2.2.0 Dima$ /Applications/MAMP/bin/php/php5.4.3/bin/phpize 
-bash: /Applications/MAMP/bin/php/php5.4.3/bin/phpize: Permission denied

Now i checked for permissions on these files in Finder and it shows that I have full permission to read and write the files this folder. I am a little lost. Any help would be appreciated greatly. I can post any additionally information if it would be helpful to diagnose this problem.

Had the same problem, but found a better solution

xDebug is already in MAMP.

Check your php.ini

/Applications/MAMP/conf/php5.x/php.ini

Go all the way down. You will see

[xdebug]
;zend_extension="/Applications/MAMP/bin/php5.X/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"

change that into

[xdebug]
zend_extension="/Applications/MAMP/bin/php5.X/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler=dbgp

Restart server... DONE!

See: https://web.archive.org/web/20151107210347/http://danpolant.com/want-to-run-xdebug-mamp-is-the-easiest-way/

I tried the above and i didn't quite work for me, so I Googled some more and here's what did the trick.

  1. Download and unpack the MAMP Components from SourceForge

  2. Make a note of the path(s) that were not found during the phpize process, for me it was:

     /Applications/MAMP/bin/php/php5.2.17/include/php/main/php.h /Applications/MAMP/bin/php/php5.2.17/include/php/Zend/zend_modules.h /Applications/MAMP/bin/php/php5.2.17/include/php/Zend/zend_extensions.h
  3. Create the required path in your MAMP php directory, again for me it was

    /include/php/
  4. Ensure the correct permissions on the directory

  5. Find the components for your target PHP version (in my case 5.2.17) and copy them into the path you created in step 3.

  6. Run the instructions for using the correct version of phpize from the Xdebug site

I hope that helps someone else as it took me waaaay too long to solve this!

After more research and trial and error i managed to install it after doing the following things:

  1. In Terminal, I ran chmod u+x /Applications/MAMP/bin/php/php5.4.3/bin/* To open execute permission on phpize and everything else in that path
  2. Following this article to install command line tools
  3. Following this article to install the latest autoconf and related tools
  4. After that following the steps provided by the XDebug Wizard worked without a hitch

This was a major headache though. Hopefully this answer will save someone else a bit of time in the future.

It's important to point out that the instructions in the "solution" are for Xdebug2 we are at xdebug3 these days.

To enable xdebug3 in MAMP on macOS do this:

  • Open Tools → phpinfo
  • Locate the line Loaded Configuration File and copy the complete path ( /Application/MAMP/...... ) of the php.ini file.
  • Open a Terminal and type the following command open and paste the copied complete path of the active php.ini file.
  • Add the following lines
[xdebug]
zend_extension = xdebug
xdebug.mode = debug
xdebug.show_local_vars=1
  • Restart the MAMP Webserver.

Check phpinfo again (refresh) and lookout for a line under ZEND engine stating with Xdebug vX.XX...

If this doesn't appear check for spelling mistakes, or other typos.

Consult the xdebug documentation for additional settings which can be added at the php.ini file you opened. If you change the PHP version you will have to repeat the procedure.

Alternatively buy a MAMP Pro license that allows to do this from the MAMP control panel.

its easy in C:\\MAMP\\conf\\php xxx \\ directory and open each php.ini related and then just put this lines in php.ini

    [xdebug]

xdebug.default_enable=1

xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1

zend_extension="C:\MAMP\bin\php\php5.5.0\ext\php_xdebug.dll"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM