linux下针对php7搭建workerman环境

1、利用php -v命令查看当前的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、根据版本下载PHP源代码

PHP历史版本下载页面:http://php.net/releases/
我下载的是 php-7.0.27,大的版本一致即可

3、解压源码压缩包

例如下载的压缩包名称是php-7.0.27.tar.gz

 tar -zxvf   php-7.0.27.tar.gz

4、进入源码中的ext/pcntl目录

~# cd php-7.0.27/ext/pcntl/

5、运行 phpize 命令

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

6、运行 configure命令

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

7、运行 make 命令

[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、运 行make install 命令

~#  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、配置ini文件

通过运行 php –ini查找php.ini文件位置,然后在文件中添加extension=pcntl.so

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)

发现没有这个配置文件,把生效的php.ini文件复制一份过去

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

再查询时就有东西了

 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

重启php,提示没有这个扩展模块

/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

把生成的扩展文件复制到提示的扩展路径中

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

再次重启

/etc/init.d/php-fpm restart

猜你喜欢

转载自blog.csdn.net/zhq_zvik/article/details/79259107
今日推荐