内容目录
如果出现,请求http://127.0.0.1:9502报如下错误:
Windows命令行:
curl http://127.0.0.1:9502
报错:curl: (52) Empty reply from server浏览器访问:
http://127.0.0.1:9501
报错:127.0.0.1 未发送任何数据。ERR_EMPTY_RESPONSE
- 提示服务器未回复数据
解决方法
- 一:检查项目是否启动,未启动则去到下一步:进入容器并启动 Hyperf 服务
- 二:打开
D:\docker\www\myhyperf\hyperf-skeleton\config\autoload
目录下的server.php
文件(D:\docker\www\myhyperf是本机的hyperf项目目录),检查里面的port(默认是9501)是否与创建容器的主机端口一致,不一致则修改成一致(因为示例里创建容器的端口是9502所以这里也需要改成9502),然后进入容器,重新启动项目
<?php declare(strict_types=1); /** * This file is part of Hyperf. * * @link https://www.hyperf.io * @document https://hyperf.wiki * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ use Hyperf\Server\Event; use Hyperf\Server\Server; use Swoole\Constant; return [ 'mode' => SWOOLE_PROCESS, 'servers' => [ [ 'name' => 'http', 'type' => Server::SERVER_HTTP, 'host' => '0.0.0.0', // 'port' => 9501, 'port' => 9502, 'sock_type' => SWOOLE_SOCK_TCP, 'callbacks' => [ Event::ON_REQUEST => [Hyperf\HttpServer\Server::class, 'onRequest'], ], ], ], 'settings' => [ Constant::OPTION_ENABLE_COROUTINE => true, Constant::OPTION_WORKER_NUM => swoole_cpu_num(), Constant::OPTION_PID_FILE => BASE_PATH . '/runtime/hyperf.pid', Constant::OPTION_OPEN_TCP_NODELAY => true, Constant::OPTION_MAX_COROUTINE => 100000, Constant::OPTION_OPEN_HTTP2_PROTOCOL => true, Constant::OPTION_MAX_REQUEST => 100000, Constant::OPTION_SOCKET_BUFFER_SIZE => 2 * 1024 * 1024, Constant::OPTION_BUFFER_OUTPUT_SIZE => 2 * 1024 * 1024, ], 'callbacks' => [ Event::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'], Event::ON_PIPE_MESSAGE => [Hyperf\Framework\Bootstrap\PipeMessageCallback::class, 'onPipeMessage'], Event::ON_WORKER_EXIT => [Hyperf\Framework\Bootstrap\WorkerExitCallback::class, 'onWorkerExit'], ], ];
进入容器并启动 Hyperf 服务
docker exec -it myhyperf /bin/sh
cd /data/project/hyperf-skeleton
php bin/hyperf.php start
然后在浏览器内访问http://127.0.0.1:9502/,查看运行结果
0 条评论
撰写评论