温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何在Centos7中安装swoole扩展

发布时间:2021-02-25 16:57:40 来源:亿速云 阅读:194 作者:Leah 栏目:开发技术

这篇文章将为大家详细讲解有关如何在Centos7中安装swoole扩展,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

PHP版本为PHP 7.2.24

  1. 更新源

[root@localhost html]# yum update
  1. 安装需要支持的扩展

[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
  1. 安装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.net/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 https://github.com/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后面
  1. 修改配置

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

[root@localhost html]# /bin/systemctl restart php-fpm.service
[root@localhost html]# /bin/systemctl restart httpd.service
  1. 验证是否安装成功

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

如何在Centos7中安装swoole扩展

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

关于如何在Centos7中安装swoole扩展就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI