Introduction
FOSSBilling is an open-source billing solution that is perfect for managing your subscriptions, invoices, and payments. In this guide, we’ll walk you through setting up FOSSBilling on your VPS using Docker, making the process easier and more efficient. Docker will help you deploy FOSSBilling in isolated containers, ensuring a smooth installation and simplified management.
Let’s get started with a step-by-step guide to install FOSSBilling on your server using Docker, Docker Compose, and MariaDB for the database.
Prerequisites
Before you begin, make sure you have the following:
- A VPS running Ubuntu 24 (or similar version).
- A non-root user with
sudoprivileges (for security purposes). - Docker and Docker Compose installed.
- A domain (optional, for production use) pointing to your VPS.
- Basic knowledge of the command line interface (CLI).
Step 1: Update Your System
Before we begin, it’s essential to update your system to ensure all packages are up to date. This will help avoid conflicts during the installation process.
This will update all system packages.
Step 2: Install Docker and Docker Compose
FOSSBilling will run in Docker containers, so you’ll need to install Docker and Docker Compose.
Install Docker:
Install Docker Compose:
Allow Docker to run without
sudo:This allows you to run Docker commands without needing
sudo.Verify the Installation:
Check the Docker and Docker Compose versions to ensure they were installed correctly:
Step 3: Set Up FOSSBilling with Docker Compose
Now that Docker and Docker Compose are installed, let’s set up FOSSBilling.
Create a directory for FOSSBilling:
Create the Docker Compose file:
You’ll need to create a
docker-compose.ymlfile to define the services for FOSSBilling and MariaDB.Add the following content to the file:
- This configuration sets up two containers: one for FOSSBilling (
fossbilling) and one for the MariaDB database (db). - Make sure to replace the database password and other credentials if necessary.
- This configuration sets up two containers: one for FOSSBilling (
Start the Containers:
Run the following command to start FOSSBilling and its database container:
Verify the Containers Are Running:
You can check if the containers are running by using the following command:
You should see both the FOSSBilling container and the MariaDB container listed.
Step 4: Access FOSSBilling Setup Wizard
FOSSBilling is now running in Docker. To complete the setup, open your browser and navigate to:
Follow the installation wizard:
Database Configuration:
- Database Host:
db - Database Name:
fossbilling - Database User:
fossbilling - Database Password:
fossbillingpass
- Database Host:
Admin User:
- Create your admin account by providing an email and password.
Once completed, you will see a success message confirming that FOSSBilling has been successfully installed.
Step 5: Final Configuration
Remove the Installer Folder:
After installation, you should delete the installer folder for security reasons:
Change Config File Permissions:
Set the
config.phpfile to read-only to enhance security:Set Up Cron Jobs:
Add the following cron job to run the FOSSBilling cron script every 5 minutes:
Add this line to the crontab file:
Step 6: Secure FOSSBilling with SSL (Optional but Recommended)
If you are using a domain (e.g., billing.gethostpro.com), it’s a good idea to secure your FOSSBilling installation with SSL.
Install Nginx Proxy Manager: If you haven’t already, install Nginx Proxy Manager to handle reverse proxies and SSL certificates for your domain.
Configure Nginx Proxy Manager:
- Add a Proxy Host for
billing.gethostpro.comto forward traffic to your Docker container (running FOSSBilling on port 8080). - Enable SSL with Let’s Encrypt and configure automatic redirection from HTTP to HTTPS.
- Add a Proxy Host for
Step 7: Set Up Backups for FOSSBilling
It’s essential to set up automated backups for your FOSSBilling files and MariaDB database to prevent data loss.
Create a Backup Script:
Add the following content to the script:
Make the Script Executable:
Set Up Cron Job for Backups:
Schedule the backup to run daily at 2 AM:
Add the following line:
Conclusion
Congratulations! You’ve successfully set up FOSSBilling on your VPS using Docker. Your FOSSBilling instance is now up and running, and you’ve implemented essential features like SSL, cron jobs, and automated backups.
If you want to explore more advanced configurations, such as custom billing features, performance optimizations, or advanced security measures, feel free to dive deeper into the official FOSSBilling documentation.
