最近公司需要搭建Phabricator服務(wù),用到了LAMP套件,其中在配置PHP時(shí),需要擴(kuò)展'pcntl'使用多進(jìn)程,但在擴(kuò)展時(shí)遇到了麻煩:
系統(tǒng):
Mac OSX EI Capitan
PHP版本信息:(Mac OSX自帶)
PHP 5.5.27 (cli) (built: Aug 22 2015 18:20:44)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
具體情況如下:
使用 cpoptdeiMac:phabricator cpopt$ ./bin/phd start
命令,終端提示
ERROR: The PHP extension 'pcntl' is not installed. You must install it to run daemons on this machine.
網(wǎng)上的安裝'pcntl'基本上都是下面的方法:
首先下載一個(gè)php-5.4.24源代碼包
進(jìn)入源代碼目錄的 ext/pcntl/
cd /path/to/phpsrc/ext/pcnt/
phpize
make
sudo
make install
最后記得要修改系統(tǒng)php的php.ini,加載pcntl.so模塊
我嘗試了上面的方法,重新下載了一個(gè)對應(yīng)版本的PHP安裝包,執(zhí)行上面的命令,但一直報(bào)下面的錯(cuò)誤:
cpoptdeiMac:pcntl cpopt$ pwd
/Users/cpopt/Downloads/php-5.5.27/ext/pcntl
cpoptdeiMac:pcntl cpopt$ phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
cpoptdeiMac:pcntl cpopt$
于是我又Google了半天,找到這個(gè)問題的解決方案如下,但是也是出錯(cuò),提示非法操作
cpopt$ sudo?ln?-s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include
目前為止,已經(jīng)耗了一天時(shí)間了還沒有解決,希望大家能夠幫助我渡過難關(guān)!謝謝!
認(rèn)證高級PHP講師
我也有類似的報(bào)錯(cuò):
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
最后在stackoverflow 上找到一個(gè)類似的問題
xcode-select —install
先安裝 xcode命令行工具就可以了,原因暫時(shí)不知
./configure
sudo make
sudo make install
最后出現(xiàn)錯(cuò)誤(移動so文件出問題)
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20121212/
cp: /usr/lib/php/extensions/no-debug-non-zts-20121212/#INST@5555#: Operation not permitted
make: *** [install-modules] Error 1
就是sudo自己移動也出問題
cp: /usr/lib/php/extensions/no-debug-non-zts-20121212/pcntl.so: Operation not permitted
默認(rèn)的php擴(kuò)展庫的位置不能移動進(jìn)去,就移動自己建的目錄中,之后再配置設(shè)置自己的文件目錄就行了
`sudo mkdir /usr/local/my-php-ext`
`sudo cp ./modules/pcntl.so /usr/local/my-php-ext/pcntl.so` (編譯好的pcntl文件在./modules 中)
sudo echo 'extension=/usr/local/my-php-ext/pcntl.so' >> /etc/php.ini
sudo apachectl restart
重啟apache
查看是否安裝成功
$ php -ini | grep pcntl
pcntl
pcntl support => enabled
PWD => /Users/andyron/myfield/www/test/php-src-php-5.5.34/ext/pcntl
_SERVER["PWD"] => /Users/andyron/myfield/www/test/php-src-php-5.5.34/ext/pcntl