其他分享
首页 > 其他分享> > swoole的安装

swoole的安装

作者:互联网

因为换了一台工作电脑 需要重新安装各种环境,这里简单记录一下swoole的安装步骤。

首先去下载它的git仓库:

$ git clone https://gitee.com/swoole/swoole.git
Cloning into 'swoole'...
remote: Enumerating objects: 91791, done.
remote: Counting objects: 100% (2995/2995), done.
remote: Compressing objects: 100% (2045/2045), done.
remote: Total 91791 (delta 1901), reused 1458 (delta 928), pack-reused 88796
Receiving objects: 100% (91791/91791), 29.61 MiB | 3.98 MiB/s, done.
Resolving deltas: 100% (71121/71121), done.

然后进入仓库:

 $ cd swoole/ 

之后开始 phpize编译:

$ phpize
Configuring for:
PHP Api Version:         20210902
Zend Module Api No:      20210902
Zend Extension Api No:   420210902
configure.ac:22: warning: $as_echo is obsolete; use AS_ECHO(["message"]) instead
build/php.m4:2111: PHP_CONFIG_NICE is expanded from...
configure.ac:22: the top level
config.m4:332: warning: The macro `AC_PROG_CC_C99' is obsolete.
config.m4:332: You should run autoupdate.
./lib/autoconf/c.m4:1659: AC_PROG_CC_C99 is expanded from...
config.m4:332: the top level
configure.ac:165: warning: The macro `AC_PROG_LIBTOOL' is obsolete.
configure.ac:165: You should run autoupdate.
build/libtool.m4:99: AC_PROG_LIBTOOL is expanded from...
configure.ac:165: the top level

因为我这用apt源安装的php 8.1  sudo apt install php8.1  。

所以你用 phpize 和 phpize8.1 是一样的。

然后开始 

$ ./configure

这一步编译执行后产生大量打印输出就不粘贴了,然后你就直接 sudo make && sudo make install 即可。

$ sudo make && sudo make install

之后就有了那个swoole.so文件,然后如果正常情况下它就已经在你那个php扩展的目录里面了

它最后两句话会告诉你

Installing shared extensions:     /usr/lib/php/20210902/
Installing header files:          /usr/include/php/20210902/

然后编辑php.ini文件,我这里是 sudo gedit /etc/php/8.1/cli/php.ini /etc/php/8.1/apache2/php.ini 

然后在里面添加一行扩展开启:

extension=swoole

如果你用的是hyperf框架的话记得额外加这个

;for swoole hyperf
swoole.use_shortname='off'

之后重启apache2

$ sudo systemctl restart apache2

好,现在swoole已经安装并配置php扩展完成。

 

标签:configure,swoole,sudo,m4,done,php,安装
来源: https://www.cnblogs.com/lizhaoyao/p/16683766.html