我的是win10下面的centos虚拟机,centos系统是7.8.2003的。php版本和swoole下面启动信息里面有展示。

安装之前要先单独创建一个目录
mkdir easy_sw && cd easy_sw
composer require easyswoole/easyswoole

不然搞得你的根目录乱糟糟的。

运行启动命令报错
php vendor/easyswoole/easyswoole/bin/easyswoole install
php easyswoole start

报错如下:

  ______                          _____                              _
 |  ____|                        / ____|                            | |
 | |__      __ _   ___   _   _  | (___   __      __   ___     ___   | |   ___
 |  __|    / _` | / __| | | | |  \___ \  \ \ /\ / /  / _ \   / _ \  | |  / _ \
 | |____  | (_| | \__ \ | |_| |  ____) |  \ V  V /  | (_) | | (_) | | | |  __/
 |______|  \__,_| |___/  \__, | |_____/    \_/\_/    \___/   \___/  |_|  \___|
                          __/ |
                         |___/
main server                   SWOOLE_WEB
listen address                0.0.0.0
listen port                   9501
ip@enp0s3                     192.168.10.136
worker_num                    8
reload_async                  true
max_wait_time                 3
pid_file                      /mnt/share/easy_sw/Temp/pid.pid
log_file                      /mnt/share/easy_sw/Log/swoole.log
user                          root
daemonize                     false
swoole version                4.5.1
php version                   7.3.18
easy swoole                   3.3.7
develop/produce               develop
temp dir                      /mnt/share/easy_sw/Temp
log dir                       /mnt/share/easy_sw/Log
[2020-06-04 09:35:43][debug][error]:[EasySwoole\Task\Worker bind /mnt/share/easy_sw/Temp/EasySwoole.TaskWorker.1.sock fail case Operation not permitted at file:/mnt/share/easy_sw/vendor/easyswoole/component/src/Process/Socket/AbstractUnixProcess.php line:31]
[2020-06-04 09:35:43][debug][error]:[EasySwoole\Task\Worker bind /mnt/share/easy_sw/Temp/EasySwoole.TaskWorker.0.sock fail case Operation not permitted at file:/mnt/share/easy_sw/vendor/easyswoole/component/src/Process/Socket/AbstractUnixProcess.php line:31]
[2020-06-04 09:35:43][debug][error]:[EasySwoole\Task\Worker bind /mnt/share/easy_sw/Temp/EasySwoole.TaskWorker.2.sock fail case Operation not permitted at file:/mnt/share/easy_sw/vendor/easyswoole/component/src/Process/Socket/AbstractUnixProcess.php line:31]
[2020-06-04 09:35:43][debug][error]:[EasySwoole\Task\Worker bind /mnt/share/easy_sw/Temp/EasySwoole.TaskWorker.3.sock fail case Operation not permitted at file:/mnt/share/easy_sw/vendor/easyswoole/component/src/Process/Socket/AbstractUnixProcess.php line:31]
[2020-06-04 09:35:43][debug][error]:[EasySwoole\EasySwoole\Bridge\BridgeProcess bind /mnt/share/easy_sw/Temp/bridge.sock fail case Operation not permitted at file:/mnt/share/easy_sw/vendor/easyswoole/component/src/Process/Socket/AbstractUnixProcess.php line:31]

根据错误信息排查到是因为没有下面的几个文件,原因是创建socket的时候系统报错Operation not permitted,根本原因是虚拟机共享目录不支持这种操作。
在这里插入图片描述
解决问题:

修改dev.php里面的缓存目录配置,使用linux系统的临时目录即可:
在这里插入图片描述

再次运行,正常。进到缓存目录查看:
在这里插入图片描述
在这里插入图片描述
如果要让外部访问还需要放行9501端口:

firewall-cmd --zone=public --add-port=9501/tcp --permanent
firewall-cmd  --reload

在这里插入图片描述

配置Nginx反向代理

因为swoole不支持完整的htpp协议,所以最好配置一下转发,以便设置域名访问。

server {
    root /mnt/share/xxx;
    server_name easy_dev.xxx.xxx.com;
    location / {
        proxy_http_version 1.1;
        proxy_set_header Connection "keep-alive";
        proxy_set_header X-Real-IP $remote_addr;
        if (!-f $request_filename) {
             proxy_pass http://127.0.0.1:9501;
        }
    }
}
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐