webman:安装/创建项目(v1.5.7)

发布时间 2023-08-19 09:06:25作者: 刘宏缔的架构森林

一,官方文档:

1,官方站:

https://www.workerman.net/webman

2,安装文档:

https://www.workerman.net/doc/webman/install.html

二,准备安装环境:

1,需求

环境需求

2,查看本地环境:php:

liuhongdi@lhdpc:~$ /usr/local/soft/php8/bin/php --version
PHP 8.1.1 (cli) (built: Dec 20 2021 16:12:16) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.1, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.1, Copyright (c), by Zend Technologies

3,查看本地环境:composer:

liuhongdi@lhdpc:~$ /usr/local/bin/composer --version
Composer version 2.5.8 2023-06-09 17:13:21

三,创建项目:

1,用命令创建

liuhongdi@lhdpc:/data/webman$ composer create-project workerman/webman imageadmin

2,调试方式启动

liuhongdi@lhdpc:/data/webman/imageadmin$ php start.php start
Workerman[start.php] start in DEBUG mode
------------------------------------------- WORKERMAN --------------------------------------------
Workerman version:4.1.13          PHP version:8.1.1           Event-Loop:\Workerman\Events\Select
-------------------------------------------- WORKERS ---------------------------------------------
proto   user            worker          listen                 processes    status           
tcp     liuhongdi       webman          http://0.0.0.0:8787    8             [OK]            
tcp     liuhongdi       monitor         none                   1             [OK]            
--------------------------------------------------------------------------------------------------
Press Ctrl+C to stop. Start success.

3,查看效果:

访问:

http://0.0.0.0:8787/

如图:

4,以生产方式(daemon)启动:

启动

liuhongdi@lhdpc:/data/webman/imageadmin$ php start.php start -d
Workerman[start.php] start in DAEMON mode
------------------------------------------- WORKERMAN --------------------------------------------
Workerman version:4.1.13          PHP version:8.1.1           Event-Loop:\Workerman\Events\Select
-------------------------------------------- WORKERS ---------------------------------------------
proto   user            worker          listen                 processes    status           
tcp     liuhongdi       webman          http://0.0.0.0:8787    8             [OK]            
tcp     liuhongdi       monitor         none                   1             [OK]            
--------------------------------------------------------------------------------------------------
Input "php start.php stop" to stop. Start success.

查看端口:

liuhongdi@lhdpc:/data/webman/imageadmin$ ss -lntp | grep 8787
LISTEN 0      4096         0.0.0.0:8787       0.0.0.0:*    users:(("php",pid=2223,fd=6),("php",pid=2222,fd=6),("php",pid=2221,fd=6),("php",pid=2220,fd=6),("php",pid=2219,fd=6),("php",pid=2218,fd=6),("php",pid=2217,fd=6),("php",pid=2216,fd=6),("php",pid=2215,fd=6))

查看进程:

liuhongdi@lhdpc:/data/webman/imageadmin$ ps auxfww
…
liuhong+    2215  0.0  0.3 416212 15564 ?        S    20:58   0:00 WorkerMan: master process  start_file=/data/webman/imageadmin/start.php
liuhong+    2216  0.0  0.4 416212 17724 ?        S    20:58   0:00  \_ WorkerMan: worker process  webman http://0.0.0.0:8787
liuhong+    2217  0.0  0.4 416212 18472 ?        S    20:58   0:00  \_ WorkerMan: worker process  webman http://0.0.0.0:8787
liuhong+    2218  0.0  0.4 416212 17912 ?        S    20:58   0:00  \_ WorkerMan: worker process  webman http://0.0.0.0:8787
liuhong+    2219  0.0  0.4 416212 17576 ?        S    20:58   0:00  \_ WorkerMan: worker process  webman http://0.0.0.0:8787
liuhong+    2220  0.0  0.4 416212 16184 ?        S    20:58   0:00  \_ WorkerMan: worker process  webman http://0.0.0.0:8787
liuhong+    2221  0.0  0.4 416212 17376 ?        S    20:58   0:00  \_ WorkerMan: worker process  webman http://0.0.0.0:8787
liuhong+    2222  0.0  0.4 416212 17136 ?        S    20:58   0:00  \_ WorkerMan: worker process  webman http://0.0.0.0:8787
liuhong+    2223  0.0  0.4 416212 17260 ?        S    20:58   0:00  \_ WorkerMan: worker process  webman http://0.0.0.0:8787
liuhong+    2224  0.0  0.4 416212 17492 ?        S    20:58   0:00  \_ WorkerMan: worker process  monitor none

5,停止进程:

liuhongdi@lhdpc:/data/webman/imageadmin$ php start.php stop
Workerman[start.php] stop 
Workerman[start.php] is stopping ...
Workerman[start.php] stop success

说明:刘宏缔的架构森林—专注it技术的博客,
网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/08/18/webman-an-zhuang-chuang-jian-xiang-mu-v1-5-7/
代码: https://github.com/liuhongdi/ 或 https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: 371125307@qq.com

四,查看webman框架的版本:

liuhongdi@lhdpc:/data/webman/imageadmin$ composer show workerman/webman-framework
name     : workerman/webman-framework
descrip. : High performance HTTP Service Framework.
keywords : High Performance, http service
versions : * v1.5.7
type     : library
...