Build a workerman environment for php7 under linux

1. Use the php -v command to view the current version of the PHP CLI

[root@iZ2ze9lk5j1zbi3qi14shwZ lib]# php -v
PHP 7.0.14 (cli) (built: Jan  1 2018 22:36:50) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

2. Download the PHP source code according to the version

PHP historical version download page: http://php.net/releases/
I downloaded php-7.0.27, the larger version can be the same

3. Unzip the source code package

For example, the downloaded compressed package name is php-7.0.27.tar.gz

 tar -zxvf   php-7.0.27.tar.gz

4. Enter the ext/pcntl directory in the source code

~# cd php-7.0.27/ext/pcntl/

5. Run the phpize command

~# phpize
Configuring for:
PHP Api Version:         20151012
Zend Module Api No:      20151012
Zend Extension Api No:   320151012

6. Run the configure command

~# ./configure
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
...

7. Run the make command

[root@iZ2ze9lk5j1zbi3qi14shwZ pcntl]# make
/bin/sh /var/www/html/php-7.0.27/ext/pcntl/libtool --mode=install cp ./pcntl.la /var/www/html/php-7.0.27/ext/pcntl/modules
cp ./.libs/pcntl.so /var/www/html/php-7.0.27/ext/pcntl/modules/pcntl.so
cp ./.libs/pcntl.lai /var/www/html/php-7.0.27/ext/pcntl/modules/pcntl.la
PATH="$PATH:/sbin" ldconfig -n /var/www/html/php-7.0.27/ext/pcntl/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /var/www/html/php-7.0.27/ext/pcntl/modules8

8. Run the make install command

~#  make install
Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20151012/
[root@iZ2ze9lk5j1zbi3qi14shwZ pcntl]# /etc/init.d/php-fpm restart
Stopping php-fpm:                                          [  OK  ]
Starting php-fpm: [05-Feb-2018 10:50:00] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pcntl.so' - /usr/lib64/php/modules/pcntl.so: cannot open shared object file: No such file or directory in Unknown on line 0

9. Configure the ini file

Find the php.ini file location by running php --ini and add extension=pcntl.so to the file

php --ini
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File:         (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

Found that there is no such configuration file, copy the valid php.ini file to the past

cp /etc/php.ini   /usr/local/lib/php.ini

When you query again, there is something

 php --ini
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File:         /usr/local/lib/php.ini
Scan for additional .ini files in: (none)
Additional .ini files pars

Restart php, it prompts that there is no such extension module

/etc/init.d/php-fpm restart
Stopping php-fpm:                                          [  OK  ]
Starting php-fpm: [05-Feb-2018 10:47:00] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pcntl.so' - /usr/lib64/php/modules/pcntl.so: cannot open shared object file: No such file or directory in Unknown on line 0

Copy the generated extension file to the prompt extension path

cp /usr/local/lib/php/extensions/no-debug-non-zts-20151012/pcntl.so  /usr/lib64/php/modules/pcntl.socp /usr/local/lib/php/extensions/no-debug-non-zts-20151012/ /usr/lib64/php

reboot again

/etc/init.d/php-fpm restart

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326847990&siteId=291194637