命令运行
swoole_http_server只能在cli环境中运行,此软件包提供了方便的artisan命令来对其进行管理。
php artisan swoole:http {start|stop|restart|reload|infos}
命令 | 描述 |
---|---|
start | 启动 Laravel Swoole |
stop | 停止 Laravel Swoole |
restart | 重新启动 Laravel Swoole |
reload | 重新加载所有工作程序(包含您的业务和Laravel / Lumen代码),但不包括主程序/危险程序 |
infos | 显示PHP和Swoole基本杂项信息(包括PHP版本,Swoole版本,Laravel版本,服务器状态和PID) |
示例:
[root@iZuf67ycxvw0ovvqhgmiv0Z current]# php artisan swoole:http infos
+-----------------+----------------------------------------------------------+
| Name | Value |
+-----------------+----------------------------------------------------------+
| PHP Version | 7.1.33 |
| Swoole Version | 4.4.13 |
| Laravel Version | 5.5.48 |
| Listen IP | 127.0.0.1 |
| Listen Port | 1215 |
| Server Status | Offline |
| Reactor Num | 1 |
| Worker Num | 1 |
| Task Worker Num | 0 |
| Websocket Mode | Off |
| PID | None |
| Log Path | /www/laravel_dev/releases/4/storage/logs/swoole_http.log |
+-----------------+----------------------------------------------------------+
启动 swoole
[deployer@iZuf67ycxvw0ovvqhgmiv0Z current]$ php artisan swoole:http start
Starting swoole http server...
Swoole http server started: <http://127.0.0.1:1215>
注意:如果提示开启 xdebug 是危险的,就需要关闭 PHP 的 Xdebug 模块。
# 查看是否开启了 Xdebug
php -v
[root@iZuf67ycxvw0ovvqhgmiv0Z current]# php -v
PHP 7.1.33 (cli) (built: Oct 26 2019 10:16:23) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.33, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans
# 关闭 Xdebug
vim /etc/php.d/xdebug.ini
# 注释掉就 OK 了