Home > Article > Backend Development > php adds pcntl extension (Linux)
php adds pcntl extension (Linux)
Published 1 year ago (2013-09-02 15:07) Reads (936) | Comments (0) 1people have collected this article,I want to collect it
January 10 #Changsha# The 32nd issue of OSC Yuanchuanghui has started to register
php Add to pcntl Extension
pcntl extension can support multi-threaded operation of php (linux only)
Originally, you need to recompile PHP and add --enable-pcnt to the configure prompt at the end
Since my php is installed using yum, so The above method cannot be used
The following is a way to dynamically add extensions to php, phpize
1. First, look at the directory where the phpize command is located (ps: my directory/usr/bin/phpize)
If not found, perform the installation
yum install php53_devel (ps: please pay attention to your own version)
After the installation is completed. The phpize command will be generated
2. Go to php.net to download the corresponding version of the php source file
Let’s take php-5.3.17 as an example. After decompression, enter the corresponding module
cd ext/pcntl
#Execute phpize first
/ usr/bin/phpize
./configure --with-php-config=/usr/bin/php-config (ps: Please specify the directory of php-config correctly)
#Compile and install
make && make install
this An error occurred
./configure compiled normally, but make error
error: 'PHP_FE_END' undeclared here (not in a function)
Solution:
There is an error in the source code, enter the php-5.3.17 directory
sed -i 's|PHP_FE_END|{NULL,NULL,NULL}|' ./ext/**/*.c
sed -i 's|ZEND_MOD_END|{NULL,NULL,NULL}|' ./ext/**/*.c
Remake make && make install
3. After compilation, a pcntl.so file will be generated . Edit /etc/php.ini in the php model directory and add
extension=pcntl.so
4. Restart apache
service httpd restart
5. Test whether the installation is successful
echo pcntl_fork();
?>
Output: 23165