Installing PCNTL for PHP on OSX Lion

php中文网
发布: 2016-07-29 09:05:35
原创
1264人浏览过
Today I needed to install the PCNTL extension for PHP for a tutorial session at the Dutch PHP Conference. And since I am working on OSX Lion, this of course gave some problems due to the rather odd installation of Apache and PHP on OSX.
Several sites on the web gave quick guides for this, but still, as always there are a few things you need to keep in mind for it all to work. I will try to walk through the process as detailed as possible:
First start by installing Xcode. You can get the latest version from the App Store. NOTE that the App Store only have the latest version of Xcode, so if you need a version for Snow Leopard or older, you need to dig deep on the web (https://connect.apple.com is a good place to start).
Next you need to install the Command Line Tools from Xcode. You do this by opening Xcode, go to Preferences (CMD + ,) -> Downloads -> Components and hit install on the Command Line Tools. You can get the Command Line Tools without installing Xcode via https://connect.apple.com
Now you need to find out what version of PHP is installed on OSX
$ php -v
PHP 5.3.10 with Suhosin-Patch (cli) (built: Feb 20 2012 22:55:53) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
and then get the source code for that version
$ curl -O http://us.php.net/distributions/php-5.3.10.tar.gz
When the download have finished, you should unpack, find the PCNTL extension, phpize, configure, make and then make install
$ tar -xzvf php-5.3.10.tar.gf 
$ cd php-5.3.10/ext/pcntl
$ phpize
$ ./configure
$ make
$ sudo make install
If phpize is complaining, you are probably missing autoconf. The easiest way to install autoconf is via Homebrew. You install Homebrew by doing
$ /usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)" 
The first thing you need to do afterwards is to run
$ brew doctor 
to find out if any dependencies are missing. Homebrew will telle you what to do, if any is missing.
Lastly you need to enable the PCNTL extension. Do this by adding the following to your php.ini
extension=pcntl.so 
if you do not know where your php.ini file are, you probably need to create on, by doing
sudo cp /private/etc/php.ini.default /private/etc/php.ini 
Restart Apache and verify that the PCNTL extension are loaded correctly
$ sudo apachectl restart 
$ php -m | grep pcntl 
pcntl
If the PCNTL extension for some reason is not loaded, try and copy the pcntl.so from the compiled source code to the extensions directory
$ sudo cp php-5.3.10/ext/pcntl/modules/pcntl.so /usr/lib/php/extensions/no-debug-non-zts-10090626/ 
Restart apache and verify the the PCNTL extension is loaded.
Resources:
  • http://blog.lancerushing.com/2011/02/getting-phps-pcntl-working-on-snow.html
  • http://stackoverflow.com/questions/8430977/phpize-wont-work-on-mac-os-x-lion
  • http://mxcl.github.com/homebrew/
  • http://stackoverflow.com/questions/9343151/where-is-php-ini-in-mac-os-x-lion-thought-it-was-in-usr-local-php5-lib
  • https://github.com/camertron/Pongo/blob/master/INSTALL_PCNTL

以上就介绍了Installing PCNTL for PHP on OSX Lion,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

相关标签:
php
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号