CentOS7 安装PHP7的swoole扩展:
一、绪
Swoole简介
PHP异步网络通信引擎
最终编译为so文件作为PHP的扩展
准备工作
Linux环境
PHP7 swoole2.1 redis
源码安装PHP7 源码安装swoole
https://www.cnblogs.com/cshaptx4869/p/10395744.html
定时器
swoole_timer_tick 每隔一定时间执行,毫秒
swoole_timer_after 一定时间后执行,毫秒
swoole_timer_clear 清除定时器
异步文件系统IO(4.3版本之前)
swoole_async_readfile 异步读取文件内容
执行顺序:1、先读取文件 2、再执行下码 3、最后执行回调
读取的文件不能超过4M
swoole_async_read
swoole_async_writefile
执行顺序和 readfile 相同
swoole_async_write
异步MySQL客户端
使用场景
请求文章详情页 -> mysql 文章+1 -> 页面数据展示
异步redis
进程
进程就是正在运行的程序的一个实例。
内存
Table
Table一个基于共享内存和锁实现的超高性能,并发数据结构。用于解决多进程/多线程数据共享和同步加锁问题。Atomic
Atomic是Swoole底层提供的原子计数操作类,可以方便整数的无锁原子增减。
协程
二、安装
> wget https://github.com/swoole/swoole-src/archive/v4.3.5.tar.gz
> tar xzvf v4.3.5.tar.gz
> cd swoole-src-4.3.5/
> phpize
> ./configure --with-php-config=/usr/local/php71/bin/php-config --enable-http2 --enable-openssl
> make && make install
> echo 'extension=swoole.so' >> /usr/local/php71/lib/php.ini
> systemctl restart php-fpm.service
如果使用hyperf框架修改php.ini配置文件
swoole.use_shortname = 'Off'
$ php --ri swoole

三、nginx+swoole配置
erver {
root /data/wwwroot/;
server_name local.swoole.com;
location / {
proxy_http_version 1.1;
proxy_set_header Connection "keep-alive";
proxy_set_header X-Real-IP $remote_addr;
if (!-e $request_filename) {
proxy_pass http://127.0.0.1:9501;
}
}
}
#通过读取$request->header['x-real-ip']来获取客户端的真实IP
四、手册
https://toxmc.github.io/swoole-cs.github.io/
demo: https://www.helloweba.net/tag/swoole.html
CentOS7 安装PHP7的swoole扩展:的更多相关文章
- centos7安装PHP7的redis扩展
前言: 在本篇博客中,我将给大家介绍如何在Centos7上安装PHP-Redis扩展,关于如何在Centos上安装redis的,可以参考另外一篇博客:Centos7安装redis 想要在php中操作r ...
- Centos7 安装php7.3 并扩展 MySQL、postgresql
首先是安装需要的扩展文件 yum -y install freetype-devel yum -y install libpng-devel yum -y install libjpeg-devel ...
- CentOS7 安装PHP7的redis扩展:
phpredis-4.2.0.tar.gz:下载:wget https://github.com/phpredis/phpredis/archive/4.2.0.tar.gz $ tar -z ...
- Centos7 安装PHP7版本及php-fpm,redis ,php-redis,hiredis,swoole 扩展安装
============================PHP7.1 ========================================= 1. 更换rpm 源,执行下面两个 rpm - ...
- Centos7安装gearman和php扩展
Centos7安装gearman和php扩展 标签(空格分隔): php,linux gearman所需要的依赖 yum install \ vim \ git \ gcc \ gcc-c++ \ w ...
- centos6下安装php7的memcached扩展
安装php7的memcached扩展 .编译安装libmemcached- wget https://launchpadlibrarian.net/165454254/libmemcached-1.0 ...
- window下安装php7的memcache扩展
安装memcache:http://www.runoob.com/memcached/memcached-connection.html1.4.4 c:\memcached\memcached.exe ...
- php----------linux下安装php的swoole扩展
1.首先你已经安装好了php环境,这里就不介绍php环境的安装了.如果你是编译安装记得将php加入环境变量,以便于方便查看扩展是否安装成功. 2.我安装的php环境缺少了要给东西,详细看下图 如果你没 ...
- CentOS7 安装 PHP7.2
点击查看原文 安装源 安装 EPEL 软件包: $ sudo yum install epel-release 安装 remi 源: $ sudo yum install http://rpms.re ...
随机推荐
- 正则去掉 html标签
var htmlStr='<p class="cjk" style="margin-bottom: 0cm; line-height: 16px;"> ...
- SpringCloud或SpringBoot+Mybatis-Plus利用mybatis插件实现数据操作记录及更新对比
引文 本文主要介绍如何使用mybatis插件实现拦截数据库操作并根据不同需求进行数据对比分析,主要适用于系统中需要对数据操作进行记录.在更新数据时准确记录更新字段 核心:mybatis插件(拦截器). ...
- 【JavaWeb】Spring入门——HelloWorld
0.为什么要使用Spring https://www.cnblogs.com/zmmi/p/7922186.html 1. 下载jar包 https://blog.csdn.net/qq_435401 ...
- 兵贵神速!掌握这10个Python技巧,让你代码工作如鱼得水
主题 Python 1000个读者心中有1000个哈姆雷特,要问1000个程序员“什么才是最好的语言”,Java.Python.PHP.C++ 也都有自己的位置.但要问编程语言流行指数之王非,那真的非 ...
- DAY1小题
F 求逆序对的板子题 #include<cstdio> #define ll long long using namespace std; ; ll a[maxn],r[maxn],n; ...
- 绕过QQ群文件下载限速
绕过QQ群文件下载限速 引言 众所周知,用QQ客户端下载QQ群文件,速度往往被限为10KB/s.这里我们来讲讲如何绕过这一限制. 原始事件发生在2020年2月2日,值武汉疫情爆发,全国各省市纷纷下令推 ...
- python学习笔记:分支 与 循环
if 语句 if 条件: ...... # 条件为真的时候,执行缩进的代码 if 条件: ...... # 条件为真的时候执行 else: ...... # 条件为假的时候执行 if 条件1: ... ...
- [LeetCode] 735. Asteroid Collision
行星碰撞. 题意是给一个数组 asteroids,表示在同一行的行星.对于数组中的每一个元素,其绝对值表示行星的大小,正负表示行星的移动方向(正表示向右移动,负表示向左移动).每一颗行星以相同的速度移 ...
- openfire 安装配置时出现The Openfire database schema does not appear to be installed. Follow the installati错误的解决方案
最近再弄openfire用openLDAP整合,本来没整合的时候选的标准数据库没问题,但是现在用嵌入式数据库,就报错了,,, 报错原因:没有导入openfire的数据表 解放办法: 1.登陆数据库 , ...
- 使用13行Python代码实现四则运算计算器函数
原创的刷新行数记录的代码!!! 支持带小括号,支持多个连续+-号,如-7.9/(-1.2-++--99.3/-4.44)*---(2998.654+-+-+-(+1.3-7.654/(-1.36-99 ...