{"id":13673828,"url":"https://github.com/shidazhuang/myTinyWebServer","last_synced_at":"2025-04-28T13:32:05.274Z","repository":{"id":217590222,"uuid":"500051033","full_name":"shidazhuang/myTinyWebServer","owner":"shidazhuang","description":null,"archived":false,"fork":false,"pushed_at":"2022-06-05T09:21:00.000Z","size":19397,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-11T14:39:43.627Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shidazhuang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-06-05T09:18:08.000Z","updated_at":"2022-06-05T09:21:03.000Z","dependencies_parsed_at":"2024-01-17T09:32:24.544Z","dependency_job_id":null,"html_url":"https://github.com/shidazhuang/myTinyWebServer","commit_stats":null,"previous_names":["shidazhuang/mytinywebserver"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shidazhuang%2FmyTinyWebServer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shidazhuang%2FmyTinyWebServer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shidazhuang%2FmyTinyWebServer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shidazhuang%2FmyTinyWebServer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shidazhuang","download_url":"https://codeload.github.com/shidazhuang/myTinyWebServer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251319757,"owners_count":21570451,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T11:00:25.161Z","updated_at":"2025-04-28T13:32:00.248Z","avatar_url":"https://github.com/shidazhuang.png","language":"C++","funding_links":[],"categories":["Projects"],"sub_categories":["Cpp"],"readme":"\n\nTinyWebServer\n===============\nLinux下基于C++的轻量级Web服务器注释、修改版本.\n原项目来自:https://github.com/qinguoyi/TinyWebServer\n\n**有什么特点？**\n* 使用 **线程池 + 非阻塞socket + epoll(ET和LT均实现) + 事件处理(Reactor和模拟Proactor均实现)** 的并发模型\n* 使用**状态机**解析HTTP请求报文，支持解析**GET和POST**请求\n* 访问服务器数据库实现web端用户**注册、登录**功能，可以请求播放服务器**图片和视频文件**\n* 实现**同步/异步日志系统**，记录服务器运行状态\n* 经Webbench压力测试可以实现**上万的并发连接**数据交换\n-----\n快速运行\n------------\n* 服务器测试环境\n\t* Ubuntu版本16.04\n\t* MySQL版本5.7.29\n* 浏览器测试环境\n\t* Windows、Linux均可\n\t* Chrome\n\t* FireFox\n\t* 其他浏览器暂无测试\n\n* 测试前确认已安装MySQL数据库\n\n    ```C++\n    // 建立yourdb库\n    create database yourdb;\n\n    // 创建user表\n    USE yourdb;\n    CREATE TABLE user(\n        username char(50) NULL,\n        passwd char(50) NULL\n    )ENGINE=InnoDB;\n\n    // 添加数据\n    INSERT INTO user(username, passwd) VALUES('name', 'passwd');\n    ```\n\n* 修改main.cpp中的数据库初始化信息\n\n    ```C++\n    //数据库登录名,密码,库名\n    string user = \"root\";\n    string passwd = \"root\";\n    string databasename = \"yourdb\";\n    ```\n\n* build 编译项目\n\n    ```C++\n    sh ./build.sh\n    ```\n\n* 启动server服务器项目\n\n    ```C++\n    ./server\n    ```\n\n* 浏览器端 打开指定网页\n\n    ```C++\n    127.0.0.1:9006\n    ```\n\n个性化运行\n------\n\n```C++\n./server [-p port] [-l LOGWrite] [-m TRIGMode] [-o OPT_LINGER] [-s sql_num] [-t thread_num] [-c close_log] [-a actor_model]\n```\n\n温馨提示:以上参数不是非必须，不用全部使用，根据个人情况搭配选用即可.\n\n* -p，自定义端口号\n\t* 默认9006\n* -l，选择日志写入方式，默认同步写入\n\t* 0，同步写入\n\t* 1，异步写入\n* -m，listenfd和connfd的模式组合，默认使用LT + LT\n\t* 0，表示使用LT + LT\n\t* 1，表示使用LT + ET\n    * 2，表示使用ET + LT\n    * 3，表示使用ET + ET\n* -o，优雅关闭连接，默认不使用\n\t* 0，不使用\n\t* 1，使用\n* -s，数据库连接数量\n\t* 默认为8\n* -t，线程数量\n\t* 默认为8\n* -c，关闭日志，默认打开\n\t* 0，打开日志\n\t* 1，关闭日志\n* -a，选择反应堆模型，默认Proactor\n\t* 0，Proactor模型\n\t* 1，Reactor模型\n\n测试示例命令与含义\n\n```C++\n./server -p 9007 -l 1 -m 0 -o 1 -s 10 -t 10 -c 1 -a 1\n```\n\n- [x] 端口9007\n- [x] 异步写入日志\n- [x] 使用LT + LT组合\n- [x] 使用优雅关闭连接\n- [x] 数据库连接池内有10条连接\n- [x] 线程池内有10条线程\n- [x] 关闭日志\n- [x] Reactor反应堆模型\n\n致谢\n------------\nLinux高性能服务器编程，游双著.\n源码来自：https://github.com/qinguoyi/TinyWebServer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshidazhuang%2FmyTinyWebServer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshidazhuang%2FmyTinyWebServer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshidazhuang%2FmyTinyWebServer/lists"}