1. 下载swoole
http://pecl.php.net/package/swoole
2. 安装swoole扩展
tar zxvf swoole-4.4.12.tgz
cd swoole-4.4.12
phpize
./configure --with-php-config=/usr/local /php/bin/php-config
make && make install
echo "extension=swoole.so" >> /usr/local/php/etc/php.ini
/etc/init.d/php-fpm restart
3. 查看是否安装成功
php -m | grep swoole
4. Laravel6 安装 swoole
composer require swooletw/laravel-swoole
添加服务提供者到config/app.php
'providers' => [
SwooleTW\Http\LaravelServiceProvider::class,
],
5. 发布(不发布的话storage下的log会没日志 )
php artisan vendor:publish --tag=laravel-swoole
6. 安装成功,运行成功
![](https://img.haomeiwen.com/i11595166/f0ab753fe32256b9.png)
7. 查看版本或帮助
php artisan help swoole:http # 查看帮助
php artisan swoole:http start # 启动服务
php artisan swoole:http restart # 重启服务
php artisan swoole:http reload # 热更新swoole服务
php artisan swoole:http infos # 查看版本
![](https://img.haomeiwen.com/i11595166/8b4aeb3882b8bcf5.png)
swoole 使用确实爽速度快了好多倍, 之前需要一百多毫秒的一个接口现在一个接口8,9 毫秒就搞定了。
相关网页: https://github.com/swooletw/laravel-swoole
swoole + inotify 热更新
相关web
1. 安装包
http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
2. 使用方法及测试方法
https://blog.csdn.net/zz_aiytag/article/details/107826135
3. centos7.2 rsync + inotify 安装使用实时备份
https://blog.csdn.net/weixin_39963973/article/details/78551926
4 . 报错处理
error while loading shared libraries: libinotifytools.so.0: cannot open shared object file
https://blog.csdn.net/wangxin6722513/article/details/44218893
安装shell
#!/bin/bash
cd /tmp
wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
tar zxvf inotify-tools-3.14
cd /tmp/inotify-tools-3.14
./configure –prefix=/usr/local/inotify
make && make install
echo "/usr/lib64/mysol" >> /etc/ld.so.conf
ldconfig
export LD_LIBRARY_PATH=/usr/local/inotify/lib:$LD_LIBRARY_PATH
测试脚本 /tmp/demo.sh , 当/tmpsrcdir 有变化 时就会执行
#!/bin/bash
srcdir=/tmp/srcdir
inotifywait -rq --timefmt '%d/%m/%y-%H:%M' --format '%T %w%f' -e modify,create,attrib ${srcdir} \
| while read file
do
echo "${file} is notified!"
done
网友评论