1.修改/web/tool/demo/server下新建http_server.php
```
<?php
$http = new swoole_http_server("0.0.0.0", 9503);
$http->set(
[
'enable_static_handler' => true,
'document_root' => "/web/tool/demo/html",//静态文件路径
]
);
$http->on('request', function($request, $response) {
$response->cookie("singwa", "xsssss", time() + 1800);
//$response->end("<h1>hello world!</h1>");
$response->end("sss". json_encode($request->get));
});
$http->start();
```
2.新建/web/tool/demo/html下新建test.html
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
我是通过http server 获取的静态资源内容
</body>
</html>
```
3.在浏览器访问
![](https://img.kancloud.cn/1d/69/1d69a79c84d2361014dd007c92a94f2d_965x300.png)