kangle环境是一款国产的WEB服务器是跨平台、轻量级、易上手、功能强大的高性能web和反向代理服务器软件。kangle的适用平台也很广泛如:Linux、Windows、Freebsd等等这些平台都可以编译安装。

在GitHub的页面查看发现作者还在更新,这里就要尝鲜安装一下。

使用环境 Debian 12.5

这里的参考脚本来源:funnycups/kangle

一键脚本安装

不想折腾的伙伴,可以使用脚本一键安装,脚本来源GitHub。

1
curl -s https://raw.githubusercontent.com/funnycups/kangle/main/install.sh|bash

安装相关依赖

1
2
3
4
apt update -y
apt install -y git cmake make curl wget zip unzip build-essential zlib1g zlib1g-dev libssl-dev\
libevent-dev libjpeg-dev libpng-dev libtiff-dev pkg-config autoconf bison re2c libxml2-dev libsqlite3-dev\
libcurl4-gnutls-dev libfreetype-dev libonig-dev

安装kangle支持的新特征

HTTP3 和 zstd 支持

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#brotli
wget https://github.com/google/brotli/archive/refs/tags/v1.0.9.tar.gz -O brotli.tar.gz
tar zxf brotli.tar.gz
rm -rf brotli.tar.gz
cd brotli-1.0.9
mkdir out
cd out
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF ..
cmake --build . --config Release --target install

#zstd
git clone https://github.com/facebook/zstd

#pcre
wget jaist.dl.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz?viasf=1 -O pcre.tar.gz
tar zxf pcre.tar.gz
rm -rf pcre.tar.gz
cd pcre-8.45
mkdir build
cd build
cmake -DCMAKE_C_FLAGS=-fPIC DCMAKE_CXX_FLAGS=-fPIC ..
make && make install

安装kangle环境

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# kangle
git clone https://github.com/litespeedtech/lsquic
cd lsquic && git submodule update --init --recursive
cd ~/install
git clone https://github.com/google/boringssl
git clone https://github.com/keengo99/kangle
cd kangle
git submodule update --init --recursive
mkdir build
cd build
mkdir -p /vhs/kangle
cmake -DCMAKE_INSTALL_PREFIX=/vhs/kangle -DZSTD_DIR=~/install/zstd -DENABLE_BROTLI=ON -DBORINGSSL_DIR=~/install/boringssl -DLSQUIC_DIR=~/install/lsquic ..
make && make install

#kangle service
touch /lib/systemd/system/kangle.service;
cat >>/lib/systemd/system/kangle.service<<EOF
[Unit]
Description=Kangle Web Service
After=syslog.target network.target
[Service]
Type=forking
ExecStart=/vhs/kangle/bin/kangle
ExecStop=/vhs/kangle/bin/kangle -q
[Install]
WantedBy=multi-user.target
EOF

ln -s /lib/systemd/system/kangle.service /etc/systemd/system/multi-user.target.wants/kangle;
systemctl daemon-reload;
systemctl enable kangle;

安装kwebp组件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#install kwebp
cd ~/install
git clone https://github.com/webmproject/libwebp
cd libwebp
mkdir build && cd build
cmake .. -D CMAKE_C_FLAGS=-fPIC
make && make install
cd ~/install
git clone https://github.com/keengo99/kwebp
cd kwebp
mkdir build && cd build
cmake .. -DKANGLE_DIR=/vhs/kangle -DLIBWEBP_DIR=~/install/libwebp
make
make install

安装Kwaf组件

1
2
3
4
5
6
7
8
9
#install kwaf
cd ~/install
git clone https://github.com/keengo99/kwaf
cd kwaf
sed -i "s/set(CMAKE_INSTALL_PREFIX \${KANGLE_DIR})//" CMakeLists.txt
mkdir build && cd build
cmake .. -DKANGLE_DIR=~/install/kangle -DCMAKE_INSTALL_PREFIX=/vhs/kangle
make
make install

部分配置参数

1
2
3
4
5
6
#set etc config
cd /vhs/kangle/etc
wget -O config.xml https://raw.githubusercontent.com/funnycups/kangle/main/config.xml

#start Kangle
systemctl start kangle

安装完成,浏览器打开 IP:3311 进行访问/