一、安装VMware
链接:参考Vm虚拟机安装Linux系统教程
二、下载Centos文件
下载链接:centos-vault-7.7.1908-isos-x86_64安装包下载_开源镜像站-阿里云
三、创建虚拟机
参考:超详细VMware CentOS7(有可视化界面版)安装教程_vm安装centos7图形界面-CSDN博客
网络选择桥接模式
四、测试网络ping www.baidu.com
五、更换yum源
这里Centos7 yum的时候会失败,需要更新yum源
//查看已经安装好的yum源仓库
yum repolist
备份旧源
//备份系统旧配置文件
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
下载新源(选择其一即可)
//阿里云yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
//腾讯云yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
//华为云yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo
//网易云yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
更新源
//清除原有yum缓存
yum clean all
//刷新缓存
yum makecache
六、安装宝塔
直接到宝塔官网复制linux安装命令
七、安装swoole
1. 下载swoole源码,官网:PECL :: Package :: swoole 挑选自己的版本下载,
在这里下载:swoole-4.6.7
解压到/www/server/php/80目录下,
进入:/www/server/php/80/swoole-4.6.7 文件夹下;
执行以下命令安装(三行命令一起复制,粘贴运行):
phpize
./configure --with-php-config=/www/server/php/80/bin/php-config
make && sudo make install
当停到这里时,按回车键就行
安装swoole扩展
(1) 测试TCP 服务器
官方文档:Swoole4 文档
3.1.1、创建网站同时创建文件server.php
官方文档:Swoole4 文档
3.1.2、运行命令server.php
进入网站的根目录再运行
出现错误:PHP Fatal error: Uncaught Error: Class 'Swoole\Server' not found in /www/wwwroot/wss.xxx.com.cn/server.php
参考:
解决Class 'swoole_server' not found - 程序生(Codey) - 博客园
swoole错误“Uncaught Error: Class 'swoole_server' not found”的解决办法_weixin_30248399的博客-CSDN博客
这里因为php.ini配置中没有加入extension=swoole.so
但是我们查看PHP.8 ini的文档中是已经加入的,但是还是出现这个错误,
用命令查看扩展
php -m
再运行命令server.php 没有显示错误,也没有显示任何内容,此时说明是对的
telnet 127.0.0.1 9501
telnet 没有安装直接运行 yum install telnet -y
感谢大神
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/haibo0668/article/details/118092473