可视化完成 SWS 在 Debian 12 的安装、用户创建及多域名虚拟主机配置
curl --proto '=https' --tlsv1.2 -sSfL https://get.static-web-server.net | sh
wget --https-only --secure-protocol=TLSv1_2 -qO- https://get.static-web-server.net | sh
wget https://github.com/static-web-server/static-web-server/releases/download/v2.41.0/static-web-server-v2.41.0-x86_64-unknown-linux-gnu.tar.gz
scp static-web-server-v2.41.0-x86_64-unknown-linux-gnu.tar.gz root@your-server-ip:/tmp/
cd /tmp tar -xzf static-web-server-v2.41.0-x86_64-unknown-linux-gnu.tar.gz
mv static-web-server-v2.41.0-x86_64-unknown-linux-gnu/static-web-server /usr/local/bin/
chmod +x /usr/local/bin/static-web-server chown root:root /usr/local/bin/static-web-server
static-web-server --version
rm -rf /tmp/static-web-server-v2.41.0-x86_64-unknown-linux-gnu*
mkdir -p /etc/sws
nano /etc/systemd/system/static-web-server.service
[Unit] Description=Static Web Server After=network.target [Service] AmbientCapabilities=CAP_NET_BIND_SERVICE CapabilityBoundingSet=CAP_NET_BIND_SERVICE Type=simple User=www Group=www WorkingDirectory=/var/www ExecStart=/usr/local/bin/static-web-server -w /etc/sws/sws.toml Restart=always RestartSec=5 [Install] WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable static-web-server
groupadd -r www
useradd -r -g www -s /usr/sbin/nologin -d /var/www -m www
mkdir -p /var/www/domains/default chown -R www:www /var/www chmod -R 755 /var/www
id www
/var/www/domains/{domain},未匹配域名指向 /var/www/domains/default
输入域名,系统会自动生成对应的根目录路径
暂无域名,请在上方添加
nano /etc/sws/sws.toml
chown www:www /etc/sws/sws.toml chmod 644 /etc/sws/sws.toml
mkdir -p /var/www/domains/example.com chown www:www /var/www/domains/example.com
-u www /usr/local/bin/static-web-server -w /etc/sws/sws.toml
systemctl start static-web-server systemctl status static-web-server
journalctl -u static-web-server -f