如何在PHP MAMP中启用过程控制扩展(PCNTL)? [英] how to enable process control extension (PCNTL) in PHP MAMP?

查看:242
本文介绍了如何在PHP MAMP中启用过程控制扩展(PCNTL)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有MAMP,我需要在当前的MAMP安装中启用-pcntl. 我该怎么办?


I have MAMP and I need to enable -pcntl on my current MAMP installation. How can I do so?

感谢您的帮助.

推荐答案

有一种方法可以编译PCNTL作为扩展并将其链接到现有的PHP构建中,但这有点深入.

There is a way of compiling PCNTL as an extension and linking it in to an existing PHP build, but it's a bit in-depth.

我正在使用MAMP和PHP版本5.3.6的Mac OSX Snow Leopard(64位)上执行以下操作.如果您的PHP版本号不同,请记住在以下几行中更改PHP版本号!

I'm doing the following on Mac OSX Snow Leopard (64bit), with MAMP and PHP version 5.3.6. Remember to change PHP version numbers in the following lines if yours is different!

请注意,make是必需的,默认情况下未在Mac OSX上安装.您需要通过Mac开发人员工具 http://developer.apple.com/unix/

Please note that make is required, which isn't installed by default on Mac OSX. You need to install this via Mac developer tools, http://developer.apple.com/unix/

首先,下载与您在MAMP中使用的版本匹配的PHP源代码的tar(例如,我的版本为5.3.6),您可以在http://www.php.net/releases/.将CD和CD解压缩到 php- [version]/ext/pcntl ,例如:

First, download a tar of the PHP source code that matches the version you are using in MAMP (e.g. mine is 5.3.6), which you can do at http://www.php.net/releases/. Untar and CD to php-[version]/ext/pcntl, e.g.:

$ wget http://museum.php.net/php5/php-5.3.6.tar.gz
$ tar xvf php-5.3.6.tar.gz
$ cd php-5.3.6/ext/pcntl

然后,您需要在pcntl目录中运行phpize,该目录是MAMP随附的二进制文件:

You then need to run phpize in the pcntl directory, which is a binary file that comes with MAMP:

pcntl$ /Applications/MAMP/bin/php/php5.3.6/bin/phpize

这将创建准备编译扩展所需的一堆文件.

This creates a bunch of files that are needed for preparing a extension for compiling.

我们现在需要添加一些标志,以告知它使用32位和64位双体系结构编译该库,因为MAMP PHP是以这种方式构建的.如果不这样做,则编译后的共享库将无法工作.

We now need to add some flags to tell it to compile the library with dual 32bit and 64bit architecture, as the MAMP PHP has been built this way. If you don't do this, the compiled shared objects won't work.

pcntl$ MACOSX_DEPLOYMENT_TARGET=10.6
pcntl$ CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"
pcntl$ CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
pcntl$ CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
pcntl$ LDFLAGS="-arch i386 -arch x86_64 -bind_at_load"
pcntl$ export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET

然后我们可以运行./configuremake来构建共享对象:

We can then run ./configure and make to build our shared object:

pcntl$ ./configure
pcntl$ make

这会将名为pcntl.so的文件放置在 modules 目录中.将此文件复制到MAMP的PHP扩展目录:

This puts a file called pcntl.so in the modules directory. Copy this file to your MAMP's PHP extensions directory:

pcntl$ cp modules/pcntl.so /Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/

最后,编辑PHP INI文件以包含扩展名:

Finally, edit the PHP INI file to include the extension:

$ echo "extension=pcntl.so" >> /Applications/MAMP/bin/php/php5.3.6/conf/php.ini

PCNTL现在应该启用.要检查是否已添加,只需运行:

PCNTL should now be enabled. To check to see whether it has been added, just run:

$ /Applications/MAMP/bin/php/php5.3.6/bin/php --ri pcntl

pcntl

pcntl support => enabled

如果您看到了,那就行了!如果有任何问题,您可以从MAMP PHP扩展目录中删除pcntl.so文件并删除INI设置,然后重试.

If you see that, it's worked! If anything has gone wrong you can just remove the pcntl.so file from the MAMP PHP extensions directory and remove the INI setting, and try again.

这篇关于如何在PHP MAMP中启用过程控制扩展(PCNTL)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆