Systemd
Introduction
With Systemd, we can run any application as a service.
FastAPI
As an example, consider running the FastAPI framework:
- Create a website using the "Systemd" template.

- Connect to the server via SSH as the root user.
- Install the required packages:
Debian/Ubuntu:
apt update && apt install python3-pip python3-venv -y
Rocky Linux/AlmaLinux:
yum install python3-pip python3-virtualenv -y
- Switch to your site’s system user:
su - yoursiteuser
Replace yoursiteuser with the actual username.
note
You can determine the site user in the site card, field "Site user". To change the site user password, go to "Management" → "Users" section in FASTPANEL®.
- Create a virtual environment and activate it:
python3 -m venv myenv
source myenv/bin/activate
Replace myenv with the desired environment name.
- Install the required packages for FastAPI:
pip install fastapi uvicorn
- Deactivate the virtual environment:
deactivate
- Create a file
main.pyin the website directory with the following content:
import os
import uvicorn
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"hello": "world"}
if __name__ == "__main__":
port = int(os.getenv("SERVICE_PORT", 8000))
uvicorn.run(app, host="0.0.0.0", port=port)
- In the site dashboard, go to “Settings” → “Backend”.
- Set "Launch command" to:
python3 main.py - Save and check the website
Logs
A Systemd service can generate logs. In FASTPANEL®, they are located in the site dashboard, in the "Logs" section, under the "Backend log" tab.