轉自:https://www.pianshen.com/article/2575340971/
ubuntu16,php7.0:安裝多進程模塊pcntl
1、首先檢查php版本號
-
php -v
-
//輸出版本號:我的是php7.0.33
2、下載對應版本的php包
-
//我的是進入到/home下,創建php目錄,把包下載到php目錄中去
-
cd /home/php/
-
//然後下載對應的php包
-
wget http://cn2.php.net/distributions/php-7.0.33.tar.bz2
3、解壓縮包
-
// -C 的作用是解壓到指定目錄,這裏解壓到當前目錄下
-
tar xvjf php-7.2.8.tar.bz2 -C .
4、進入到php的ext/pcntl下
cd /home/php/php-7.0.33/ext/pcntl/
5、執行的phpize命令(phpize命令是用來擴展php模塊的)
phpize
發現這一步報錯了,報錯如下:
-
root@ubuntu-virtual-machine:/home/php/php-7.0.33/ext/pcntl/# phpize
-
程序“phpize”尚未安裝。 您可以使用以下命令安裝:
-
apt install php7.0-dev
提示沒有安裝phpize,那就按照他給的提示,使用命令:apt install php7.0-dev命令進行安裝:
-
root@ubuntu-virtual-machine:/home/php/php-7.0.33/ext/pcntl/# apt install php7.0-dev
-
正在讀取軟件包列表... 完成
-
正在分析軟件包的依賴關係樹
-
正在讀取狀態信息... 完成
-
下列軟件包是自動安裝的並且現在不需要了:
-
libboost-program-options1.58.0 libboost-thread1.58.0 libgoogle-perftools4 libsnappy1v5 libtcmalloc-minimal4 libv8-3.14.5
-
libyaml-cpp0.5v5 linux-headers-4.15.0-29 linux-headers-4.15.0-29-generic linux-headers-4.15.0-43
-
linux-headers-4.15.0-43-generic linux-image-4.15.0-29-generic linux-image-4.15.0-43-generic linux-modules-4.15.0-29-generic
-
linux-modules-4.15.0-43-generic linux-modules-extra-4.15.0-29-generic linux-modules-extra-4.15.0-43-generic mongodb-clients
-
mongodb-server
-
使用'sudo apt autoremove'來卸載它(它們)。
-
將會同時安裝下列軟件:
-
autoconf automake autotools-dev debhelper dh-php dh-strip-nondeterminism libfile-stripnondeterminism-perl libltdl-dev
-
libmail-sendmail-perl libpcre3-dev libpcre32-3 libsigsegv2 libssl-dev libssl-doc libsys-hostname-long-perl libtool m4
-
php-pear php-xml php7.0-xml pkg-php-tools po-debconf shtool
-
建議安裝:
-
autoconf-archive gnu-standards autoconf-doc dh-make libtool-doc gfortran | fortran95-compiler gcj-jdk libmail-box-perl
-
下列【新】軟件包將被安裝:
-
autoconf automake autotools-dev debhelper dh-php dh-strip-nondeterminism libfile-stripnondeterminism-perl libltdl-dev
-
libmail-sendmail-perl libpcre3-dev libpcre32-3 libsigsegv2 libssl-dev libssl-doc libsys-hostname-long-perl libtool m4
-
php-pear php-xml php7.0-dev php7.0-xml pkg-php-tools po-debconf shtool
-
升級了 0 個軟件包,新安裝了 24 個軟件包,要卸載 0 個軟件包,有 123 個軟件包未被升級。
-
需要下載 6,485 kB 的歸檔。
-
解壓縮後會消耗 28.2 MB 的額外空間。
-
您希望繼續執行嗎? [Y/n] y
-
獲取:1 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 libsigsegv2 amd64 2.10-4 [14.1 kB]
-
獲取:2 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 m4 amd64 1.4.17-5 [195 kB]
-
獲取:3 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 autoconf all 2.69-9 [321 kB]
-
獲取:4 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 autotools-dev all 20150820.1 [39.8 kB]
-
獲取:5 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 automake all 1:1.15-4ubuntu1 [510 kB]
-
獲取:6 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 po-debconf all 1.0.19 [234 kB]
-
獲取:7 http://cn.ar
-
.....
-
..
-
.
-
後面的就省略了。。。。。
6、上面執行成功後就是執行phpize命令了
-
root@ubuntu-virtual-machine:/home/php/php-7.0.33/ext/pcntl# phpize
-
Configuring for:
-
PHP Api Version: 20151012
-
Zend Module Api No: 20151012
-
Zend Extension Api No: 320151012
7、執行配置命令
root@ubuntu-virtual-machine:/home/php/php-7.0.33/ext/pcntl# ./configure --with-php-config=/usr/bin/php-config
8、執行安裝和編譯命令
-
root@ubuntu-virtual-machine:/home/php/php-7.0.33/ext/pcntl# make && make install
-
//執行完了該條命令後,最後會輸出結果:
-
//Installing shared extensions: /usr/lib/php/20151012/
-
表示安裝完成
9、給php添加擴展:extension=pcntl.so,進入到php下的fpm文件中,編輯php.ini
root@ubuntu-virtual-machine:/etc/php/7.0/fpm# vim php.ini
添加 extension=pcntl.so
10、重啓php7.0-fpm服務
service php7.0-fpm restart
重啓後打印phpinfo();可以看到擴展了
ok,結束!