/usr/lib/systemd/system文件夹下新建indexsite.service
[Unit]
Description=Index Site
[Service]
User=nobody
WorkingDirectory=/var/www/index
ExecStart=/usr/bin/env python3 server.py
Restart=always
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start indexsite
sudo systemctl enable indexsite