ubuntu编译安装swoole

安装openssh-server

sudo apt-get install openssh-server -y

修改su密码

# 回车输入两次密码即可,忽略系统提示的任何文字,系统只提示密码过简,不会拦截修改。
sudo password root

安装php7.3

sudo apt-get update && apt-get upgrade
sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update -y
sudo apt-get install -y php7.3

安装php7.3-dev

编译swoole需要phpize,所以安装php开发版,得到编译工具。如果是运行swoole,只安装它即可。

sudo apt-get install php7.3-dev -y

安装php-mbstring

默认php是不带mbstring的,但think-swoole依赖mbstring扩展

sudo apt-get install php7.3-mbstring -y

安装编译环境

sudo apt-get install gcc-4.8 make autoconf -y

编译swoole源码

# 进入swoole源码目录
cd swoole
phpize && ./configure && make && sudo make install

配置php扩展

extension=swoole.so

查看是否加载扩展

php -m

编译问题

  1. configure: error: Cannot find php-config. Please use --with-php-config=PATH

    编译前运行./configure --with-php-config=/path/xxx

    查找php-config路径:find -name php-config

  2. Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script

    apt-get install autoconf -y
  3. gcc-c++

    apt-get install build-essential

ubuntu编译安装swoole
http://blog.icy8.cn/posts/55819/
作者
icy8
发布于
2021年4月15日
许可协议