鍍金池/ 問答/Java  PHP/ php如何增加加擴展

php如何增加加擴展

環(huán)境是linux+nginx
想添加pcntl擴展
百度了下重新編譯加
在原來編譯參數(shù) --enable-pcntl 加上這個 重新編譯 然后make 也重啟了nginx 可是這個擴展還是沒加到


后記 我服務(wù)器欠缺點東西
yum install m4
yum install autoconf
然后在phpize
make clean
然后編譯才通過的

回答
編輯回答
抱緊我

2make 是用來編譯的,它從Makefile中讀取指令,然后編譯。

3make install是用來安裝的,它也從Makefile中讀取指令,安裝到指定的位置。

2018年5月10日 22:04
編輯回答
尐潴豬

pcntl是可以動態(tài)安裝,不需要重新編譯php
安裝方法參進官網(wǎng)說明
pcntl installation

-- php源碼自帶有pcntl擴展,無需另外下載
nechtan$ sudo su
sh-3.2# tar -zxvf php-5.3.15.tar.gz
sh-3.2# cd php-5.3.15/ext/pcntl/
sh-3.2# phpize && ./configure && make && make install 
-- make是編譯,還要執(zhí)行make install來安裝。如果安裝目錄是不默認(rèn)的。./configure操作還要指定php-coinfig目錄,--with-php-config=$DIR/php-config
sh-3.2# echo "extension=pcntl.so" >> /etc/php.ini
sh-3.2# apachectl restart

checking if everything is ok.

sh-3.2# php -m | grep pcntl
pcntl

注:nginx是http服務(wù)器,不是php的運行環(huán)境,php相關(guān)的變更,應(yīng)該是重啟php運行環(huán)境,比如例子提到的apache,此外常用的還有php-fpm等,取決于你使用的什么

2017年11月23日 18:34
編輯回答
寫榮

這樣是靜態(tài)編譯進php的方式,比較麻煩,建議使用動態(tài)加載方式進行擴展添加

1.進入pcntl擴展目錄執(zhí)行phpize
2.執(zhí)行./configure --with-php-config=/usr/bin/php-config
3.make && make install 這樣擴展文件pcntl.so就被放置到了/usr/lib64/php/modules(可能會有nts-nodebug這樣的子目錄)文件夾下了
4.然后在php.ini中開啟該擴展:extension=pcntl.so
5.重啟fpm或reload
2018年4月23日 00:09