Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

how to enable process control extension (PCNTL) in PHP MAMP?


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

Thanks for your help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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!

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/

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

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.

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

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

pcntl$ ./configure
pcntl$ make

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/

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 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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...