首先swoole的下载地址是:
https://github.com/swoole/swoole-src/releases
http://pecl.php.net/package/swoole
http://git.oschina.net/swoole/swoole
以上三个地址都是官方文档给出的,第二个是扩展安装,就不多说,其他两个下载它们的源码需要用到git 我们先来看看我们是否有安装过Git
git --version #用于查看我们的Git版本号,如果没有那就是没有安装,使用 yum install git 即可安装
OK,进入正题 1.下载swoole源码包
cd /usr/local/src #一般我们会把源码包放在这里
git clone http://git.oschina.net/swoole/swoole #选择这个是因为这个下载速度快
cd swoole
/usr/local/php/bin/phpize #侦测环境(phpize工具是在php安装目录下,基于这点phpize对应了当时的php环境,所以是要根据该php的配置情况生成对应的configure文件) 建立一个configure文件
./configure --with-php-config=/usr/local/php/bin/php-config
#这样swoole 就会被安装在 /usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/ 下[no-debug-non-zts-20170718文件夹不是一模一样的] ,否则则会被安装在/usr/lib64/php/modules/ 下。
make && make install #安装
以上执行完成会出现以下效果:
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/
Installing header files: /usr/local/php/include/php/
最后找到pnp.ini 在最下面添加
[swoole] extension=swoole.so
重启php-fpm /etc/init.d/php-fpm restart
systemctl restart nginx
php --ri 'swoole'这样也能看到你安装的swoole版本 完事.
已有 0 位网友参与,快来吐槽:
发表评论