Reputation: 2664
I'm wondering how to enable pcntl extension in PHP7 running on Ubuntu server 16.04.
I saw this http://www.crimulus.com/2010/07/30/howto-enable-pcntl-in-ubuntu-php-installations/ but do we really have to recompile PHP7?
It surprises me as other extensions are usually simple to add with apt-get.
Thanks
Upvotes: 10
Views: 35415
Reputation: 439
for ubuntu 18 and 20:
php -v
result for example: PHP 7.4.10
sudo wget https://www.php.net/distributions/php-7.4.10.tar.gz
replace 7.4.10 with your php version.
sudo tar xfz php-7.4.10.tar.gz && sudo rm -rf php-7.4.10.tar.gz
replace 7.4.10 with your php version.
cd php-7.4.10/ext/pcntl/
replace 7.4.10 with your php version.
sudo phpize
if phpize is not installed you can install it with apt install php7.0-dev
sudo ./configure --with-php-config=/usr/bin/php-config
sudo make && sudo make install
the result must be like Installing shared extensions: /usr/lib/php/20190902/
cd ../../../ && sudo rm -rf php-7.4.10
replace 7.4.10 with your php version.
cd /etc/php/7.4
replace 7.4 with your php version.
sudo sh -c "echo 'extension=pcntl.so' > ./mods-available/pcntl.ini"
sudo nano ./cli/php.ini
then add extension=pcntl
.
repeat this job for sudo nano ./apache2/php.ini
or sudo nano ./fpm/php.ini
.
in all above php.ini
there is disable_functions
that include pcntl
prefix. you must enable which one you want.
restart your apache2 or fpm with:
sudo service apache2 restart
sudo service php7.4-fpm restart
replace 7.4 with your php version.
you can check it with die(extension_loaded('pcntl'));
in test.php
note: if you got error : PHP Warning: Module 'pcntl' already loaded in Unknown on line 0
, remove extension=pcntl
only in cli/php.ini
Upvotes: 11
Reputation: 3712
According to your needs, the solution for me was to use the following tutorial from HowToForge.
Today, current release is 7.4.11
, but you can change it.
cd /tmp
wget https://www.php.net/distributions/php-7.4.11.tar.gz
tar xfz php-7.4.11.tar.gz
cd php-7.4.11
On the next you will find --enable-pcntl
what is the interesting thing.
./configure --prefix=/opt/php-7.4 --with-pdo-pgsql --with-zlib-dir --with-freetype --enable-mbstring --enable-soap --enable-calendar --with-curl --with-zlib --enable-gd --with-pgsql --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --with-zip --with-pdo-mysql --with-mysqli --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-jpeg --with-openssl --with-fpm-user=www-data --with-fpm-group=www-data --with-libdir=/lib/x86_64-linux-gnu --enable-ftp --with-imap --with-imap-ssl --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-intl --with-pear --enable-fpm
Please follow the entire tutorial for a complete working solution here : https://www.howtoforge.com/tutorial/how-to-compile-and-install-php-7.4-on-ubuntu-18-04/
Upvotes: 1
Reputation: 1840
You don't need apt-get install anything else.
pcntl module was included when you installed php by package manager, try to sudo apt update
then sudo apt-get upgrade
, it may be helpful.
You can also use this to confirm if you have or don't have it.
php -i | grep pcntl
//pcntl suppport=>enable
Also list all my installed module by package manager.
sudo apt install php7.0 php7.0-cli php7.0-common php7.0-fpm php7.0-imap php7.0-json php7.0-mbstring php7.0-opcache php7.0-readline php7.0-xml
Upvotes: 12