Centos7安装swoole扩展操作示例


本文实例讲述了centos7安装swoole扩展操作。分享给大家供大家参考,具体如下:

我的php版本为php 7.2.24
    更新源

[root@localhost html]# yum update



    安装需要支持的扩展

[root@localhost html]# yum install php72w-devel
[root@localhost html]# yum install php72w-pear
[root@localhost html]# yum install gcc
[root@localhost html]# yum install gcc-c++
[root@localhost html]# yum install gcc-g77



    安装swoole

[root@localhost html]# pecl install swoole
...
// 是否启用 php sockets 支持
enable sockets supports? [no] : yes
// 是否启用 openssl 支持
enable openssl support? [no] : yes
// 是否启用 http2 支持
enable http2 support? [no] : yes
// 是否启用 mysql 原生支持
enable mysqlnd support? [no] : yes


安装成功


build process completed successfully
installing '/usr/lib64/php/modules/swoole.so'
installing '/usr/include/php/ext/swoole/config.h'
install ok: channel://pecl.php/swoole-4.4.12
configuration option "php_ini" is not set to php.ini location
you should add "extension=swoole.so" to php.ini


安装失败


php startup: unable to load dynamic library 'swoole.so' (tried: /usr/lib64/php/modules/swoole.so (/usr/lib64/php/modules/swoole.so: cannot open shared object file: no such file or directory), /usr/lib64/php/modules/swoole.so.so (/usr/lib64/php/modules/swoole.so.so: cannot open shared object file: no such file or directory)) in unknown on line 0
// 把extension=swoole.so加到socket的加载后面,在php7.2中进入/etc/php.d下,在sockets.ini中将extension=swoole.so加到extension=sockets.so下面,后重启php-fpm


php -m或者 phpinfo()查看不到swoole

解决方法:

1. 确认安装和配置是否有问题
2、如果使用php -m无法查看swoole,请使用命令service php-fpm restart重启
3、如果使用phpinfo()无法查看swoole,请使用命令service httpd restart重启


c++ preprocessor “/lib/cpp” fails sanity check
// 没有c++库
// yum install glibc-headers
// yum install gcc gcc-c++ gcc-g77


fatal error: openssl/ssl.h: no such file or directory
// 没有openssl/ssl此类文件或目录
// yum install openssl-devel


error “enable http2 support, require nghttp2 library.
// wget github/nghttp2/nghttp2/releases/download/v1.34.0/nghttp2-1.34.0.tar.bz2
// tar -xjf nghttp2-1.34.0.tar.bz2


php warning: module 'swoole' already loaded in unknown on line 0
// 在修改配置时extension=swoole.so别放在最后,最好放在extension=sockets.so后面



    修改配置

[root@localhost html]# vim /etc/php.ini
...
extension=swoole.so
....



    重启

[root@localhost html]# /bin/systemctl restart php-fpm.service
[root@localhost html]# /bin/systemctl restart httpd.service



    验证是否安装成功

php -m 或者 phpinfo() 查看是否有swoole


[root@localhost /]# php --ri swoole


希望本文所述对大家centos系统配置有所帮助。


上一篇:php多进程中的阻塞与非阻塞操作实例分析

下一篇:centos7环境下swoole1.9的安装与HttpServer的使用方法分析


centos7
Copyright © 2002-2019 测速网 www.inhv.cn 皖ICP备2023010105号
测速城市 测速地区 测速街道 网速测试城市 网速测试地区 网速测试街道
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!

热门搜索 城市网站建设 地区网站制作 街道网页设计 大写数字 热点城市 热点地区 热点街道 热点时间 房贷计算器