在使用函式pcntl_fork()時報錯 Fatal error: Uncaught Error: Call to undefined function pcntl_fork()....,原因是沒有安裝pcntl擴充套件包,有兩種解決方式,一種是在編譯php的時候加上./configure --enable-pcntl,另一種是進入php原始碼的安裝目錄,執行phpize。
這裡我選擇第二種方式,進入壓縮包目錄
# pwd
/usr/local/src/php-7.1.10/ext/pcntl
# phpize
Configuring for:
PHP Api Version: 20160303
Zend Module Api No: 20160303
Zend Extension Api No: 320160303
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make && make install
----------------------------------------------------------------------
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/ //複製路徑
# vim /usr/local/php/etc/php.ini
extension= /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/pcntl.so //加入此行程式碼
修改儲存後重啟php,檢視phpinfo
OK~