1. 安装编译所需的依赖库
sudo apt update
sudo apt install -y build-essential cmake ninja-build pkg-config gcc libssl-dev libpcre3-dev libcap-dev flex hwloc libncurses-dev curl zlib1g-dev libpcre2-dev libreadline-dev
2. 安装luajit(可选,如果不需要写lua脚本的话)
# 注意,不是lua,是luajit
git clone https://luajit.org/git/luajit.git
cd luajit
make && sudo make install
cd ..
3. Traffic Server
# 下载源码
git clone https://github.com/apache/trafficserver.git
# 创建trafficserver的用户
sudo useradd tserver
chown -R tserver trafficserver #修改源码目录的所有者
cd trafficserver
# 生成编译配置,注意!不能使用root用户,不然会无法启动
sudo cmake -B build -DWITH_USER=tserver
# 开始编译,过程有点久,可以开把游戏
sudo cmake --build build
# 安装
sudo mkdir -p /usr/local/var/log/trafficserver
sudo mkdir -p /usr/local/var/trafficserver
sudo cmake --install build
sudo chown tserver /usr/local/var/log/trafficserversudo
sudo chown tserver /usr/local/var/trafficserver
sudo chown -R tserver /usr/local/trafficserver
# 启动测试
cd /usr/local/trafficserver
bin/traffic_server -R 1