dongrong1856 2012-06-06 12:19
浏览 115

Mac OSX上的MAMP和Pecl安装,用于设置PHP扩展

I had huge problems making pecl run on my MAMP 1.9 on Mac OSX and after spending a day on this whole thing I solved it, so I thought I'd share it with the others. If you know a better way to do that, perhaps you could tell me?

Basically, the problem was that I needed to install a few PHP extensions on my MAMP system and in order to do that I needed either pecl or compiler to work. None were functioning though. So the first thing I did was to upgrate to MAMP 2. Then after this I added the path to the MAMP's pecl to the ./profile typing into terminal:

echo "export PATH=/Applications/MAMP/bin/php/php5.3.6/bin:$PATH" >> ~/.profile

You can then check if your call for pecl is referring to the "correct" version (and not Mac Osx's internal one) by typing in:

which pecl

Now in order to be able to build the extensions using pecl we need to prepare the build environment for them to compile correctly. A good advice is given on this page. In short, you need to download MAMP's libraries from their website, then choose the folder with PHP that corresponds to your currently activated version (in my case it was php-5.3.6) and copy it to /Applications/MAMP/bin/php/php5.3.6/include folder. After that you should go into that folder in terminal and run

./configure

Now, this will work only if you have XCode installed. The problem though is even if it's installed, the newer versions of XCode doesn't include command-line tools such as gcc compilers (that you need) by default. So what you need to do is to either download it through XCode or from Apple's website. Once you download these command line tools you should have gcc installed and the ./configure command should work fine.

If that's not the case, you could also install MacPort and then use it to install gcc and autoconf – the tools needed for compiling.

port install autoconf

Although it may be that they are already working as part of XCode's command line tools.

In any case, after all that is done, you'll finally be able to run ./configure in your php source folder, have it prepared for future work and you can check if it functions by typing in:

pecl install uploadprogress

(in order to have that extension initialized you'll probably need to add extensions=uploadprogress.so into your php.ini file)

That's all, I just thought I'd lay it all out, because it took me hours to find the right sequence of actions and I hope it will save time for someone else. If you have ideas for how it could be done more efficiently, let me know.

  • 写回答

1条回答 默认 最新

  • dt246813579 2014-07-30 08:02
    关注

    I struggled with installing because MAMP libraries are no longer publicly available.

    But you can download the latest php version here -: http://php.net/releases/index.php, extract it's content and insert it here.

    The path looks like this for me /Applications/MAMP/bin/php/php5.5.3/include/php . I manually create the folder include, and then the extracted download content here in the php folder.

    After that ./configure worked, and then I just did pecl install uploadprogress. Add that extension to the relevant php.ini file (for the version) -: extensions=uploadprogress.so into your php.ini

    Cheers Pratik

    评论

报告相同问题?

悬赏问题

  • ¥20 matlab计算中误差
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊