How To Install FOSSBilling on Ubuntu 24.04 LTS
FOSSBilling is a powerful open-source billing and client management solution designed for hosting providers, web agencies, and online businesses. As a robust alternative to commercial billing software, it offers comprehensive features for invoice management, client support, and service automation without licensing costs. Running FOSSBilling on Ubuntu 24.04 LTS provides a stable, secure foundation for your billing operations, ensuring reliability for years to come.
This comprehensive guide walks you through the complete installation process of FOSSBilling on Ubuntu 24.04 LTS using the LEMP stack (Linux, Nginx, MySQL/MariaDB, PHP). By the end, you’ll have a fully functional billing platform with secure HTTPS encryption ready to manage your business operations efficiently.
Prerequisites
- A server running Ubuntu 24.04 LTS with at least 2GB RAM and 20GB storage space
- Root or sudo privileges on your server
- A registered domain or subdomain pointing to your server’s IP address
- Basic familiarity with Linux command line operations
- Open ports 22 (SSH), 80 (HTTP), and 443 (HTTPS) in your firewall
- A backup of your server if installing on an existing production system
While FOSSBilling can run on modest hardware, allocating adequate resources ensures optimal performance, particularly when managing numerous clients or processing frequent transactions. For production environments, consider using a VPS or dedicated server rather than shared hosting to maintain control over system resources and configurations.
Setting Up the Server Environment
First, update your Ubuntu system to ensure all packages are current:
sudo apt update && sudo apt upgrade -y
Install essential tools that will be needed throughout the installation process:
sudo apt install curl wget unzip git software-properties-common apt-transport-https ca-certificates -y
Set the correct timezone for accurate billing and scheduling:
# Check current timezone
timedatectl
# List available timezones
timedatectl list-timezones | grep -i your_region
# Set your timezone (replace with your actual timezone)
sudo timedatectl set-timezone Region/City
For security purposes, create a dedicated non-root user with sudo privileges:
# Create new user
sudo adduser fossbilling_admin
# Add user to sudo group
sudo usermod -aG sudo fossbilling_admin
Configure a basic firewall with UFW to protect your server:
# Install UFW if not already available
sudo apt install ufw -y
# Allow SSH connections
sudo ufw allow ssh
# Allow web traffic
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
# Enable firewall
sudo ufw enable
Installing Nginx Web Server
Nginx will serve as our web server for FOSSBilling, offering excellent performance for serving web applications:
# Install Nginx
sudo apt install nginx -y
# Start and enable Nginx service
sudo systemctl start nginx
sudo systemctl enable nginx
# Verify status
sudo systemctl status nginx
You can verify Nginx is working by navigating to your server’s IP address in a web browser. You should see the default Nginx welcome page.
Optimize Nginx for better performance by modifying its configuration:
# Create configuration backup
sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
# Edit configuration file
sudo nano /etc/nginx/nginx.conf
Modify the http
block with these optimized settings:
http {
# Basic settings
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
# Buffer settings
client_max_body_size 64M;
client_body_buffer_size 128k;
# Gzip compression
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# Keep existing settings below
...
}
Verify the configuration and apply changes:
sudo nginx -t
sudo systemctl reload nginx
Installing and Configuring MariaDB
FOSSBilling requires a database to store client information, invoices, and other critical data. MariaDB provides excellent performance and reliability:
# Install MariaDB server and client
sudo apt install mariadb-server mariadb-client -y
# Start and enable MariaDB
sudo systemctl start mariadb
sudo systemctl enable mariadb
Secure the MariaDB installation:
sudo mysql_secure_installation
Follow the prompts to:
- Set a strong root password
- Remove anonymous users
- Disallow root login remotely
- Remove test database and access
- Reload privilege tables
Now create a dedicated database and user for FOSSBilling:
# Log in to MariaDB
sudo mysql -u root -p
# Create database with proper encoding
CREATE DATABASE fossbilling CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# Create dedicated user
CREATE USER 'fossbilling_user'@'localhost' IDENTIFIED BY 'your_strong_password';
# Grant privileges
GRANT ALL PRIVILEGES ON fossbilling.* TO 'fossbilling_user'@'localhost';
# Apply changes
FLUSH PRIVILEGES;
# Exit
EXIT;
Optimize MariaDB performance by editing its configuration:
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
Add these settings under the [mysqld]
section:
[mysqld]
# Performance optimizations
innodb_buffer_pool_size = 256M
innodb_log_file_size = 64M
innodb_flush_log_at_trx_commit = 2
max_connections = 100
# Character set and collation
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
Restart MariaDB to apply changes:
sudo systemctl restart mariadb
Installing PHP and Required Extensions
FOSSBilling requires PHP 8.1 or newer. We’ll install PHP 8.2 with all necessary extensions:
# Add PHP repository
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
# Install PHP and required extensions
sudo apt install php8.2 php8.2-fpm php8.2-mysql php8.2-curl php8.2-gd php8.2-intl php8.2-mbstring php8.2-xml php8.2-zip php8.2-cli php8.2-common php8.2-opcache -y
Optimize PHP configuration for better performance:
# Backup original configuration
sudo cp /etc/php/8.2/fpm/php.ini /etc/php/8.2/fpm/php.ini.backup
# Edit configuration file
sudo nano /etc/php/8.2/fpm/php.ini
Modify these important settings:
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
date.timezone = "Your/Timezone" # Replace with your timezone
opcache.enable = 1
opcache.memory_consumption = 128
opcache.interned_strings_buffer = 8
opcache.max_accelerated_files = 4000
opcache.revalidate_freq = 60
Restart PHP-FPM to apply changes:
sudo systemctl restart php8.2-fpm
Verify PHP is working correctly with Nginx by creating a test file:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
Access http://your_server_ip/info.php
in your browser to confirm PHP is functioning properly. Remember to remove this file afterward for security:
sudo rm /var/www/html/info.php
Downloading and Preparing FOSSBilling Files
Now, let’s download and configure the FOSSBilling application:
# Create installation directory
sudo mkdir -p /var/www/fossbilling
# Navigate to directory
cd /var/www/fossbilling
# Download latest stable FOSSBilling release
sudo curl https://fossbilling.org/downloads/stable -L --output FOSSBilling.zip
# Extract files
sudo apt install unzip -y
sudo unzip FOSSBilling.zip
# Set proper ownership
sudo chown -R www-data:www-data /var/www/fossbilling
# Set appropriate permissions
sudo find /var/www/fossbilling -type d -exec chmod 755 {} \;
sudo find /var/www/fossbilling -type f -exec chmod 644 {} \;
The FOSSBilling directory structure should now include key folders like data
, install
, library
, modules
, themes
, and vendor
, along with important files like config-sample.php
, cron.php
, and index.php
.
Configuring Nginx for FOSSBilling
Create a server block configuration file for FOSSBilling:
sudo nano /etc/nginx/sites-available/fossbilling
Add the following configuration (replace yourdomain.com
with your actual domain):
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
root /var/www/fossbilling;
index index.php;
# Log files
access_log /var/log/nginx/fossbilling_access.log;
error_log /var/log/nginx/fossbilling_error.log;
# Handle static files efficiently
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires max;
log_not_found off;
access_log off;
}
# Block access to sensitive files
location ~ \.(htaccess|htpasswd|ini|log|sh|sql)$ {
deny all;
}
# Block hidden files
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
# PHP handler configuration
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
# URL rewriting rules
location / {
try_files $uri $uri/ /index.php?$args;
}
}
Enable the site and verify configuration:
# Create symbolic link
sudo ln -s /etc/nginx/sites-available/fossbilling /etc/nginx/sites-enabled/
# Test configuration
sudo nginx -t
# Apply changes
sudo systemctl reload nginx
Securing with SSL/TLS Certificate
Implement HTTPS to secure your FOSSBilling installation using Let’s Encrypt:
# Install Certbot with Nginx plugin
sudo apt install certbot python3-certbot-nginx -y
# Obtain and configure certificate
sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email your_email@example.com -d yourdomain.com -d www.yourdomain.com
This command will:
- Obtain a free SSL certificate
- Configure Nginx for HTTPS
- Set up automatic HTTP to HTTPS redirection
- Enable HTTP Strict Transport Security
- Configure OCSP stapling for better performance
Let’s Encrypt certificates are valid for 90 days but will automatically renew through the installed cron job. You can verify the renewal process works correctly:
sudo certbot renew --dry-run
Running the FOSSBilling Web Installer
Access your domain in a web browser (https://yourdomain.com
) to launch the FOSSBilling installer. Follow these steps:
- Review and Accept License Agreement: Check the box and click “Next”.
- System Requirements Check: The installer will verify your system meets all requirements. If issues are found, resolve them before continuing.
- Database Configuration:
- Database Type: MySQL
- Host: localhost
- Database Name: fossbilling
- Username: fossbilling_user
- Password: your_strong_password
- Administrator Account Setup:
- Username: Choose an admin username
- Email: Enter your email address
- Password: Create a strong password
- Default Currency: Select your preferred currency
- Price Format: Ensure it contains {{price}} (e.g., ${{price}})
- Click “Install” and wait for the process to complete. You should see a success message when finished.
Post-Installation Configuration
After successful installation, complete these essential steps:
- Remove the installation directory to enhance security:
sudo rm -rf /var/www/fossbilling/install
- Set proper permissions for the configuration file:
sudo chmod 640 /var/www/fossbilling/config.php sudo chown www-data:www-data /var/www/fossbilling/config.php
- Configure the required cron job for scheduled tasks:
sudo crontab -u www-data -e
Add this line to run the cron job every 5 minutes:
*/5 * * * * php /var/www/fossbilling/cron.php > /dev/null 2>&1
- Test the cron job manually:
sudo -u www-data php /var/www/fossbilling/cron.php
This cron job is critical for FOSSBilling operation – it handles renewals, expired orders, email sending, and other essential background tasks. Without it properly configured, your billing system won’t function correctly.
Basic FOSSBilling Configuration
Access the admin dashboard at https://yourdomain.com/admin
and complete these initial setup steps:
Company Information
- Navigate to System → Settings → Company
- Enter your business details, upload your logo, and add contact information
Email Configuration
- Go to System → Settings → Email
- Configure SMTP settings for reliable email delivery
- Send a test email to verify functionality
Payment Gateways
- Access System → Payment Gateways
- Set up payment processors like PayPal, Stripe, or other supported gateways
Products and Services
- Navigate to Products & Services → Products & Services
- Create your first product offerings with descriptions and pricing
- Configure product options and availability
Customer Experience
- Go to System → Customization
- Modify email templates, order forms, and client area appearance
- Adjust notification settings for clients and administrators
Explore Extensions
- Check System → Extensions
- Discover additional modules to extend functionality
Troubleshooting Common Issues
Database Connection Problems
- Verify database credentials in
config.php
- Check MariaDB service status:
sudo systemctl status mariadb
- Test database connection:
mysql -u fossbilling_user -p fossbilling
PHP Configuration Issues
- Review PHP error logs:
sudo tail -f /var/log/php8.2-fpm.log
- Verify installed extensions:
php -m
- Check memory limits:
php -i | grep memory_limit
Web Server Configuration Errors
- Examine Nginx logs:
sudo tail -f /var/log/nginx/error.log
- Validate configuration:
sudo nginx -t
- Restart Nginx if needed:
sudo systemctl restart nginx
Permission Problems
- Verify directory ownership:
ls -la /var/www/fossbilling
- Correct permissions if needed:
sudo chown -R www-data:www-data /var/www/fossbilling sudo find /var/www/fossbilling -type d -exec chmod 755 {} \; sudo find /var/www/fossbilling -type f -exec chmod 644 {} \;
SELinux Issues
If using an RHEL-derived distribution alongside Ubuntu, SELinux may cause permission problems requiring additional configuration:
semanage fcontext -a -t httpd_sys_content_t '/var/www/fossbilling(/.*)?'
restorecon -Rv /var/www/fossbilling
Cron Job Failures
- Check if an incorrect PHP version is being used for cron execution
- Try specifying the PHP binary explicitly:
*/5 * * * * /usr/bin/php8.2 /var/www/fossbilling/cron.php
- Consider using the cronjob API endpoint with wget as an alternative
Congratulations! You have successfully installed FOSSBilling. Thanks for using this tutorial to install the latest version of FOSSBilling on Ubuntu 24.04 LTS Linux system. For additional help or useful information, we recommend you check the official FOSSBilling website.