不讲skynet文件结构和详细配置,只是特此记录以后使用。
备注:skynet采用编译安装,gcc套件版本选择7.0+,lua5.3+(在安装运行中有提示)。 其它ubuntu版本可能适用此方法。 我用的是root账号,普通用户权限不够需要使用sudo
一、前期工作
1.安照惯例修改成阿里源
cp /etc/apt/sources.list /etc/apt/source.list.bak
vi /etc/apt/sources.list
清空文件粘贴以下内容:
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
apt update --更新一下
2.安装git
apt install git
3.克隆skynet和jemalloc
git clone https://github.com/cloudwu/skynet.git --skynet源码
git clone https://github.com/jemalloc/jemalloc.git --会使用到的内存管理
cp -r jemalloc/* skynet/3rd/jemalloc/ --脚本会克隆jemalloc,但是太慢了,手动克隆放进skynet的对应目录。
二、安装编译环境
1.安装工具
apt install make autoconf libreadline-dev gcc --注意gcc套件需要7.0+,我这里默认7.5
2.编译安装lua5.3.5
wget http://www.lua.org/ftp/lua-5.3.5.tar.gz
tar -zxf lua-5.3.5.tar.gz
cd lua-5.3.5
make linux test
make install
3.使用skynet自带编译好的lua
cd ~/skynet/3rd/lua --习惯使用上面自行编译的
3.编译skynet
cd ~/skynet
make linux
在/root/skynet下面生成了一个skynet可执行文件
服务端测试结果:
./skynet examples/config
客户端测试结果:
出现问题,一般是缺少组件,根据报错提示install相关功能组件。