Swoole\Server can only be used in CLI mode in
来源:4-4 Swoole - HTTP服务(上)
小冰糕
2019-08-05
在7.2php环境(lnmp安装的)+4.4.3swoole版本,运行<?php
$http = new swoole_http_server(“127.0.0.1”, 9501);
http−>on("start",function(http->on("start", function (http−>on("start",function(server) {
echo “Swoole http server is started at http://127.0.0.1:9501\n”;
});
http−>on("request",function(http->on("request", function (http−>on("request",function(request, $response) {
$response->header(“Content-Type”, “text/plain”);
$response->end(“Hello World\n”);
});
$http->start();
在linux服务器上php运行该文件后确实出现Swoole http server is started at http://127.0.0.1:9501但是因为这个服务器是阿里云服务器,已经配好了域名(配好了https),通过我本地windows电脑访问该域名下的该文件(域名/ceshi.php)后提示Fatal error: Uncaught Swoole\Exception: Swoole\Http\Server can only be used in CLI mode in /www/jianghaodong.top/ceshi.php:2 Stack trace: #0 /www/jianghaodong.top/ceshi.php(2): Swoole\Server->__construct(‘127.0.0.1’, 9501) #1 {main} thrown in /www/jianghaodong.top/ceshi.php on line 2不知道是哪里出的问题
1回答
-
singwa
2019-08-05
您好。您ceshi.php 文件是干嘛用的,代码贴出来我看看。
022019-08-05
相似问题