Debian11为例
确保已安装python3
如需安装
apt update
apt install python3
创建service
nano /etc/systemd/system/my-http-server.service
写入配置
[Unit]
Description=My HTTP Server
After=network.target
[Service]
ExecStart=/usr/bin/python3 -m http.server 8080
WorkingDirectory=/path/to/your/directory
Restart=always
[Install]
WantedBy=multi-user.target
重新加载
systemctl daemon-reload
启动服务
systemctl start my-http-server
设置开机自启
systemctl enable my-http-server
文章评论