Introduction
PocketBase is a powerful and flexible backend solution that offers real-time data synchronization, built-in authentication, and a robust API, making it an excellent choice for various applications. This tutorial provides a detailed, step-by-step guide to help you navigate through the deployment process. Whether you are a seasoned developer or just getting started, this guide will equip you with the knowledge and tools necessary to deploy a reliable and scalable PocketBase instance for your application.
Prerequisites
Before you begin, ensure you have the following:
- 1 server with Ubuntu 24.04
- You can use an Arm64 instance to get better performance compared to traditional x86 instances.
- Root access
- Basic Knowledge of Linux Command Line.
Step 1 - Prepare Your Server
Use an SSH client (PuTTY or Terminal) to connect to your server:
ssh root@<your_server_ip>
Start by updating your server with the following commands:
apt update && apt upgrade -y && apt install -y unzip
Next, create a user for PocketBase with this command:
adduser pocketbase
You'll be prompted to enter a secure password. Follow the on-screen instructions to complete the setup.
Now, switch to the new user by running:
su - pocketbase
Step 2 - Download PocketBase
Visit the PocketBase releases page and select the latest release. Choose the appropriate build for your instance — either linux_amd64
or linux_arm64
. Copy the download URL, and use wget to download the file.
Run this command to check if you have an amd64 instance or an arm64 instance.
[[ "$(uname -m)" == "x86_64" ]] && echo "amd64" || echo "arm64"
wget <url>
To unzip the downloaded archive, use the following command:
unzip <filename>
Tip: If you need to check the filename, you can list the files in the directory with:
ls
Step 3 - Configure and Create a Service
First, switch back to the root user by running:
exit
To enable the binary to bind to ports below 1024, use the following command:
setcap CAP_NET_BIND_SERVICE=+eip /home/pocketbase/pocketbase
To create a systemd service, use the following command:
bash -c 'cat <<EOF > /etc/systemd/system/pocketbase.service
[Unit]
Description=PocketBase
After=network-online.target
[Service]
User=pocketbase
WorkingDirectory=/home/pocketbase
ExecStart=/home/pocketbase/pocketbase serve --http=0.0.0.0:80
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable pocketbase.service
systemctl restart pocketbase.service'
Step 4 - Set Up an Admin Account
Open PocketBase in your browser:
http://<your_server_ip>/_
Example:
http://203.0.113.1/_
You will see the following screen:
Enter an email and a password in the respective fields. Make sure you remember the login credentials for future logins.
Then, click Create and Login.
Conclusion
Congratulations! You've successfully deployed and configured PocketBase on your server.
For further customization and advanced features, refer to the PocketBase documentation. If you encounter any issues or have questions, the PocketBase community and support resources are available to help.
Thank you for using this guide, and best of luck with your PocketBase deployment!