创建9501端口映射
ports:
- "${WORKSPACE_SSH_PORT}:22"
- "9501:9501"
创建httpServer
// 创建httpServer
$http = new swoole_http_server('0.0.0.0', 9501);
// 监听server启动事件
$http->on('start', function ($serv) {
echo "Start \n";
});
// 监听request请求
$http->on('request', function ($request, $response) {
var_dump($request->get, $request->post);
$response->header("Content-Type", "text/html; charset=utf-8");
$response->end("<h1>Hello Swoole. #</h1>" . rand(1000, 9999) . "");
});
$http->start();
进入workspace容器
docker-compose exec workspace bash
//进入workspace
php http_server.php
// 启动httpSerer

访问 http://localhost:9501

网友评论