How to Deploy a Streamlit Data Application on a VPS
Streamlit lets you build interactive data dashboards in Python. Deploy your Streamlit app on a Breeze for persistent access and sharing with your team.
Install Python and Streamlit
sudo apt update
sudo apt install -y python3 python3-pip python3-venv
# Create a virtual environment
cd /var/www/streamlit-app
python3 -m venv venv
source venv/bin/activate
pip install streamlit
Create a Sample App
# /var/www/streamlit-app/app.py
import streamlit as st
import pandas as pd
st.title("Server Metrics Dashboard")
data = pd.DataFrame({"CPU": [45, 62, 38, 71], "RAM": [60, 55, 72, 68]})
st.line_chart(data)
Create a Systemd Service
# /etc/systemd/system/streamlit.service
[Unit]
Description=Streamlit Application
After=network.target
[Service]
Type=simple
User=www-data
WorkingDirectory=/var/www/streamlit-app
ExecStart=/var/www/streamlit-app/venv/bin/streamlit run app.py --server.port 8501 --server.headless true
Restart=on-failure
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now streamlit
Reverse Proxy Configuration
server {
listen 80;
server_name dashboard.yourdomain.com;
location / {
proxy_pass http://127.0.0.1:8501;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
}
Secure with Certbot for HTTPS. Your Streamlit dashboard is now accessible on your Breeze.