How to Install PocketBase on Ubuntu 24.04
PocketBase is an open-source backend solution that provides a realtime database, authentication, file storage, and REST API—all in a single binary. This guide walks you through deploying PocketBase with systemd, creating a superuser, and securing access.
Step 1: Update and Prepare the System
First, make sure your system is up-to-date and install required dependencies:
sudo apt update && sudo apt upgrade -y
sudo apt install -y wget unzip curl git golang-go
These packages are necessary for downloading binaries, handling zip files, and optional Go development.
Step 2: Create PocketBase User and Directory
For security, run PocketBase under its own user:
sudo useradd -m -s /bin/bash pocketbase
sudo mkdir -p /opt/pocketbase
sudo chown pocketbase:pocketbase /opt/pocketbase
sudo chmod 755 /opt/pocketbase
Step 3: Download and Install PocketBase
Download the latest prebuilt Linux binary for PocketBase:
wget -O /tmp/pocketbase.zip "https://github.com/pocketbase/pocketbase/releases/download/v0.30.2/pocketbase_0.30.2_linux_amd64.zip"
sudo unzip /tmp/pocketbase.zip -d /opt/pocketbase
sudo chown -R pocketbase:pocketbase /opt/pocketbase
sudo chmod +x /opt/pocketbase/pocketbase
Create a directory for data storage:
sudo mkdir /opt/pocketbase/pb_data
sudo chown pocketbase:pocketbase /opt/pocketbase/pb_data
Step 4: Create a Systemd Service
To run PocketBase as a service and ensure it starts on boot:
sudo tee /etc/systemd/system/pocketbase.service > /dev/null <<EOF
[Unit]
Description=PocketBase service
After=network.target
[Service]
User=pocketbase
Group=pocketbase
WorkingDirectory=/opt/pocketbase
ExecStart=/opt/pocketbase/pocketbase serve --http="0.0.0.0:8090" --dir "/opt/pocketbase/pb_data"
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
Reload systemd and enable the service:
sudo systemctl daemon-reload
sudo systemctl enable pocketbase
sudo systemctl start pocketbase
Step 5: Create a Superuser
PocketBase requires a superuser for dashboard access:
sudo -u pocketbase /opt/pocketbase/pocketbase superuser upsert admin@example.com StrongPassword123! --dir /opt/pocketbase/pb_data
Replace admin@example.com
and StrongPassword123!
with your desired credentials.
Step 6: Open Firewall Port
If UFW is enabled, allow access to the PocketBase port:
sudo ufw allow 8090/tcp
Step 7: Access PocketBase
Once the service is running, you can access the dashboard:
-
URL:
http://<server-ip>:8090/_/
-
Superuser:
admin@example.com / StrongPassword123!
Conclusion
Installing PocketBase on Ubuntu 24.04 is straightforward using the prebuilt binaries and systemd service setup. By running PocketBase under its own user, creating a dedicated data directory, and enabling firewall rules, you ensure a secure and stable deployment. With the superuser account configured, you can immediately start managing your database, users, and APIs.
This setup provides a lightweight, production-ready backend that is easy to maintain, scalable, and accessible. Whether for personal projects or small-scale applications, PocketBase delivers a powerful all-in-one solution for realtime database management and API services.