FossBilling is a popular open-source billing solution that provides businesses with an intuitive interface, multiple payment gateways, and automation capabilities for invoicing, payment management, and client communication. In this guide, we will walk you through the process of installing FossBilling on a Rocky Linux 9 server, using Nginx as the web server, and securing it with SSL/TLS certificates from Let’s Encrypt. By the end of this guide, you will have a fully functional billing and client management system for your business.
Prerequisites
Before we get started, make sure you have the following requirements in place:
- A Rocky Linux 9 server with the hostname ‘fossbilling-rocky’.
- A non-root user with sudo/root administrator privileges.
- SELinux running in permissive mode.
- A domain name pointed to your server’s IP address. For this guide, we will use the sub-domain ‘fossbilling.test.host’.
Once you have these requirements met, we can proceed with the installation of FossBilling.
Installing Nginx Web Server
FossBilling can be run with either Nginx or Lighttpd web servers. In this guide, we will be using Nginx. To install Nginx, first, ensure that the EPEL repository is added to your system. If not, you can install it using the following command:
sudo dnf install epel-release
Next, install Nginx from the official Rocky Linux AppStream repository:
sudo dnf install nginx
Once Nginx is installed, start and enable the Nginx service:
sudo systemctl start nginx sudo systemctl enable nginx
To verify that Nginx is running, use the following command:
sudo systemctl status nginx
Make sure to open both HTTP and HTTPS protocols on your firewall to allow access to the Nginx server:
sudo firewall-cmd --add-service={http,https} --permanent sudo firewall-cmd --reload
With Nginx installed and configured, we can now proceed to install the MariaDB database server.
Installing MariaDB Server
FossBilling requires a MySQL or MariaDB server to store user data. For this guide, we will be using MariaDB 10.5, which is compatible with the latest version of FossBilling. Install MariaDB from the official Rocky Linux repository:
sudo dnf install mariadb-server
Start and enable the MariaDB service:
sudo systemctl start mariadb sudo systemctl enable mariadb
To verify that MariaDB is running, use the following command:
sudo systemctl status mariadb
Secure the MariaDB deployment by running the following command:
sudo mysql_secure_installation
This command will guide you through the process of securing MariaDB, including setting up a root password, removing anonymous users, disabling remote login for the root user, and removing the test database.
Next, create a new database and user for FossBilling. Log in to the MariaDB shell using the following command:
sudo mysql -u root -p
Enter your MariaDB root password when prompted. Once logged in, run the following queries to create the database and user:
CREATE DATABASE fossbillingdb; CREATE USER fossbilling@localhost IDENTIFIED BY 'password'; GRANT ALL ON fossbillingdb.* TO fossbilling@localhost WITH GRANT OPTION; FLUSH PRIVILEGES;
To verify that the user has the necessary privileges, run the following query:
SHOW GRANTS FOR fossbilling@localhost;
Exit the MariaDB shell by typing quit.
With the database and user set up, we can now proceed to install PHP and PHP-FPM.
Installing PHP-FPM 8.2
FossBilling is compatible with PHP 8.x. In this step, we will install PHP and PHP-FPM 8.2 using the Remi repository. Start by adding the Remi repository to your system:
sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-9.rpm
Reset the PHP repository module using the following command:
sudo dnf module reset php
Enable the PHP repository for version 8.2:
sudo dnf module enable php:remi-8.2
Install PHP and PHP-FPM packages:
sudo dnf install php php-fpm php-mysql php-curl php-cli php-zip php-common php-mbstring php-xml
Open the PHP configuration file for editing:
sudo nano /etc/php.ini
Modify the following lines to adjust the PHP configuration:
upload_max_filesize = 16M post_max_size = 32M memory_limit = 256M max_execution_time = 600 max_input_vars = 3000 max_input_time = 1000
Save and exit the file.
Open the PHP-FPM pool configuration file for editing:
sudo nano /etc/php-fpm.d/www.conf
Change the user and group parameters to nginx:
user = nginx group = nginx
Save and close the file.
Start and enable the PHP-FPM service:
sudo systemctl start php-fpm sudo systemctl enable php-fpm
To verify that PHP-FPM is running, use the following command:
sudo systemctl status php-fpm
Verify the installed PHP version:
php --version
With PHP and PHP-FPM installed and running, we can proceed to download the FOSSBilling source code.
Downloading FOSSBilling Source Code
Create a directory for the FOSSBilling installation:
sudo mkdir -p /var/www/fossbilling cd /var/www/fossbilling
Download the latest stable version of FOSSBilling:
sudo curl https://fossbilling.org/downloads/stable -L --output FOSSBilling.zip
Extract the downloaded archive:
sudo unzip FOSSBilling.zip
Change the ownership of the FOSSBilling installation directory to the nginx user and group:
sudo chown -R nginx:nginx /var/www/fossbilling
With the FOSSBilling source code downloaded, we can now configure the Nginx server block.
Configuring Nginx Server Block
Create a new Nginx server block configuration file:
sudo nano /etc/nginx/conf.d/fossbilling.conf
Add the following configuration to the file:
server {
listen 80;
set $root_path '/var/www/fossbilling';
server_name fossbilling.example.io;
index index.html index.htm index.php;
root $root_path;
try_files $uri $uri/ @rewrite;
sendfile off;
include /etc/nginx/mime.types;
# Block access to sensitive files and return 404 to make it indistinguishable from a missing file
location ~* .(ini|sh|inc|bak|twig|sql)$ {
return 404;
}
# Block access to hidden files except for .well-known
location ~ /\.(?!well-known\/) {
return 404;
}
# Disable PHP execution in /uploads
location ~* /uploads/.*\.php$ {
return 404;
}
# Deny access to /data
location ~* /data/ {
return 404;
}
location @rewrite {
rewrite ^/page/(.*)$ /index.php?_url=/custompages/$1;
rewrite ^/(.*)$ /index.php?_url=/$1;
}
location ~ \.php {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# fastcgi_pass need to be changed according your server setup:
# phpx.x is your server setup
# examples: /var/run/phpx.x-fpm.sock, /var/run/php/phpx.x-fpm.sock or /run/php/phpx.x-fpm.sock are all valid options
# Or even localhost:port (Default 9000 will work fine)
# Please check your server setup
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
include fastcgi_params;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
expires off;
}
}
Save and close the file.
Verify the Nginx configuration and restart the Nginx service:
sudo nginx -t
sudo systemctl restart nginx
With Nginx configured, we can now secure FOSSBilling with SSL/TLS certificates.
Securing FOSSBilling with SSL/TLS Certificates
To secure FOSSBilling with SSL/TLS certificates, we will use the Certbot tool and Let’s Encrypt. Make sure your domain name is pointed to your server’s IP address, and you have a valid email address for registration.
Install Certbot and the Certbot Nginx plugin:
sudo dnf install certbot python3-certbot-nginx
Generate SSL/TLS certificates for your domain name:
sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email[test@example.com] -d fossbilling.test.host
Follow the prompts to generate the certificates and configure HTTPS redirection.
Start FOSSBilling Installation
Open your web browser and visit your FOSSBilling installation’s domain name (e.g., https://fossbilling.test.host/).
The FOSSBilling installer will check and verify your system details. Ensure that all requirements are marked as “OK” before proceeding.
Provide the MariaDB database and user details you created earlier, and click “Next.”
Enter the administrator details for FOSSBilling, including your username, email address, password, and default currency. Click “Next” to continue.
Once the installation is complete, you will see a message confirming the successful installation of FOSSBilling.
To finalize the installation, remove the FOSSBilling “install” directory:
sudo rm -rf /var/www/fossbilling/install
Set the correct permissions for the FOSSBilling configuration file:
sudo chmod 0644 /var/www/fossbilling/config.php
Create a new cron job for FOSSBilling:
crontab -u nginx -e
Add the following line to the crontab file:
*/5**** php /var/www/fossbilling/cron.php
Save and exit the file.
Now you can access the FOSSBilling client area or admin area using the provided buttons in the web browser.
Congratulations! You have successfully installed FOSSBilling on your Rocky Linux 9 server with Nginx as the web server. Your billing and client management system is now ready to use.
Conclusion
In this guide, we have walked you through the installation process of FOSSBilling on a Rocky Linux 9 server. We started by installing and configuring the Nginx web server, followed by the installation of MariaDB as the database server. We then installed PHP and PHP-FPM, downloaded the FOSSBilling source code, and configured the Nginx server block. Finally, we secured FOSSBilling with SSL/TLS certificates using Certbot and Let’s Encrypt.
Now that you have a fully functional billing and client management system, you can streamline your invoicing, payment management, and client communication processes. FOSSBilling offers a user-friendly interface and supports multiple payment gateways, making it suitable for businesses of all sizes.
If you’re looking for reliable and scalable cloud hosting solutions, consider Shape.host’s Linux Cloud VPS services. Shape.host provides efficient and secure hosting services, empowering businesses with the resources they need to succeed in the digital world.