Jon*_*rns 59
有一种方法可以将PCNTL编译为扩展并将其链接到现有的PHP构建中,但它有点深入.
我在Mac OSX Snow Leopard(64位)上使用MAMP和PHP版本5.3.6进行以下操作.如果您的版本号不同,请记住在以下行中更改PHP版本号!
请注意,这make
是必需的,默认情况下不会安装在Mac OSX上.您需要通过Mac开发人员工具安装此工具,http://developer.apple.com/unix/
首先,下载与您在MAMP中使用的版本匹配的PHP源代码的tar(例如,我的是5.3.6),您可以在http://www.php.net/releases/上找到它.Untar和CD到php- [version]/ext/pcntl,例如:
$ 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
Run Code Online (Sandbox Code Playgroud)
然后,您需要phpize
在pcntl目录中运行,该目录是MAMP附带的二进制文件:
pcntl$ /Applications/MAMP/bin/php/php5.3.6/bin/phpize
Run Code Online (Sandbox Code Playgroud)
这会创建一组准备扩展以进行编译所需的文件.
我们现在需要添加一些标志来告诉它使用双32位和64位架构编译库,因为MAMP PHP是以这种方式构建的.如果不这样做,编译的共享对象将不起作用.
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
Run Code Online (Sandbox Code Playgroud)
然后我们可以运行./configure
并make
构建我们的共享对象:
pcntl$ ./configure
pcntl$ make
Run Code Online (Sandbox Code Playgroud)
这会将一个pcntl.so
在modules目录中调用的文件放入.将此文件复制到MAMP的PHP扩展目录:
pcntl$ cp modules/pcntl.so /Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/
Run Code Online (Sandbox Code Playgroud)
最后,编辑PHP INI文件以包含扩展名:
$ echo "extension=pcntl.so" >> /Applications/MAMP/bin/php/php5.3.6/conf/php.ini
Run Code Online (Sandbox Code Playgroud)
现在应该启用PCNTL.要检查是否已添加,只需运行:
$ /Applications/MAMP/bin/php/php5.3.6/bin/php --ri pcntl
pcntl
pcntl support => enabled
Run Code Online (Sandbox Code Playgroud)
如果你看到了,那就有用了!如果出现任何问题,您只需pcntl.so
从MAMP PHP扩展目录中删除该文件并删除INI设置,然后重试.
如果您在MAC上安装了"brew",那么您应该可以:
brew安装php53-pcntl
我不是MAMP的专家.
====编辑====(回应投票结果)
Ian-Lewiss-MacBook-Pro:~ ianlewis$ brew install php53-pcntl
Warning: php53-pcntl-5.3.25 already installed
Ian-Lewiss-MacBook-Pro:~ ianlewis$ brew info php53-pcntl
php53-pcntl: stable 5.3.25
http://php.net/manual/en/book.pcntl.php
/usr/local/Cellar/php53-pcntl/5.3.23 (3 files, 32K)
Built from source
/usr/local/Cellar/php53-pcntl/5.3.25 (3 files, 32K) *
Built from source
https://github.com/josegonzalez/homebrew-php/commits/master/Formula/php53-pcntl.rb
==> Dependencies
Build: autoconf
Required: php53
==> Options
--without-config-file
Do not add ext-pcntl.ini to /usr/local/etc/php/5.3/conf.d
--without-homebrew-php
Ignore homebrew PHP and use default instead
==> Caveats
To finish installing pcntl for PHP 5.3:
* /usr/local/etc/php/5.3/conf.d/ext-pcntl.ini was created,
do not forget to remove it upon extension removal.
* Restart your webserver.
* Write a PHP page that calls "phpinfo();"
* Load it in a browser and look for the info on the pcntl module.
* If you see it, you have been successful!
Run Code Online (Sandbox Code Playgroud)