網(wǎng)站首頁 編程語言 正文
swoole不能在windows運行,我們在linux系統(tǒng)上部署項目運行,在使用前必須安裝好swoole
linux安裝好swoole后,就可以在tp6框架下載集成 swoole模塊,如下:
使用 composer 安裝 think-swoole 擴展。即執(zhí)行 composer require topthink/think-swoole
然后在config目錄下自動生成一個swoole.php的配制文件,修改配制文件內容如下
修改監(jiān)聽IP和端口號、options 里的daemonize改成true,默認為false,之前沒有修改報很多錯誤,無法運行起來,pool連接池enable改為true
[
'host' => env('SWOOLE_HOST', '0.0.0.0'), // 監(jiān)聽地址
'port' => env('SWOOLE_PORT', 8090), // 監(jiān)聽端口
'mode' => SWOOLE_PROCESS, // 運行模式 默認為SWOOLE_PROCESS
'sock_type' => SWOOLE_SOCK_TCP, // sock type 默認為SWOOLE_SOCK_TCP
'options' => [
'pid_file' => runtime_path() . 'swoole.pid',
'log_file' => runtime_path() . 'swoole.log',
'daemonize' => true,
// Normally this value should be 1~4 times larger according to your cpu cores.
'reactor_num' => swoole_cpu_num(),
'worker_num' => swoole_cpu_num(),
'task_worker_num' => swoole_cpu_num(),
'enable_static_handler' => true,
'document_root' => root_path('public'),
'package_max_length' => 20 * 1024 * 1024,
'buffer_output_size' => 10 * 1024 * 1024,
'socket_buffer_size' => 128 * 1024 * 1024,
],
],
'websocket' => [
'enable' => false,
'handler' => Handler::class,
'ping_interval' => 25000,
'ping_timeout' => 60000,
'room' => [
'type' => 'table',
'table' => [
'room_rows' => 4096,
'room_size' => 2048,
'client_rows' => 8192,
'client_size' => 2048,
],
'redis' => [
'host' => '127.0.0.1',
'port' => 6379,
'max_active' => 3,
'max_wait_time' => 5,
],
],
'listen' => [],
'subscribe' => [],
],
'rpc' => [
'server' => [
'enable' => false,
'port' => 9000,
'services' => [
],
],
'client' => [
],
],
'hot_update' => [
'enable' => env('APP_DEBUG', true),
'name' => ['*.php'],
'include' => [app_path()],
'exclude' => [],
],
//連接池
'pool' => [
'db' => [
'enable' => true,
'max_active' => 3,
'max_wait_time' => 5,
],
'cache' => [
'enable' => true,
'max_active' => 3,
'max_wait_time' => 5,
],
//自定義連接池
],
//隊列
'queue' => [
'enable' => false,
'workers' => [],
],
'coroutine' => [
'enable' => true,
'flags' => SWOOLE_HOOK_ALL,
],
'tables' => [],
//每個worker里需要預加載以共用的實例
'concretes' => [],
//重置器
'resetters' => [],
//每次請求前需要清空的實例
'instances' => [],
//每次請求前需要重新執(zhí)行的服務
'services' => [],
];
?可以在根目錄下執(zhí)行命令? php think swoole start? 進行啟動程序,如圖下
php 安裝 fileinfo 擴展,需要解除禁用的函數(shù):putenv,proc_open
?
原文鏈接:https://blog.csdn.net/u013519290/article/details/124592745
相關推薦
- 2023-06-18 Docker之實現(xiàn)掛載的三種方式匯總_docker
- 2022-08-01 Android開發(fā)之Flutter與webview通信橋梁實現(xiàn)_Android
- 2022-06-29 python人工智能tensorflow函數(shù)np.random模塊使用_python
- 2022-09-26 MQTT android配置
- 2022-04-30 Python的進制轉換和ASCLL轉換你了解嗎_python
- 2021-12-14 go調用shell命令兩種方式實現(xiàn)(有無返回值)_Golang
- 2022-12-06 Python?if?判斷語句詳解_python
- 2022-11-05 go?module化?import?調用本地模塊?tidy的方法_Golang
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細win安裝深度學習環(huán)境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結構-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支