How to Install FossBilling with Nginx on Debian 11

How to Install FOSSBilling with Nginx on Debian 11

Are you looking for a tutorial on how to install FOSSBilling with Nginx on Debian 11? Then this guide is for you.

FOSSBilling is a free and open-source efficient billing and client management software. It’s a sound automation system for invoicing, incoming payments, and client communication. Though more suitable for hosting businesses, it also supports other online business formats.

FOSSBilling is built using PHP but uses many different libraries, languages, and technologies. You can find the software’s source code on GitHub.

In this tutorial, we’ll go over the installation details step-by-step with Nginx on a Debian device. Let’s get started!


Before installing FOSSBilling, you will need:

  • Debian 11 server installed
  • A suitable web server(Nginx in this tutorial)
  • PHP 8.0, 8.1 or 8.2
  • MySQL 8 (or higher) or MariaDB 10.3 (or higher)
  • Some PHP extensions
  • Root account or Sudo privilege

How to Install FOSSBilling with Nginx on Debian 11

Now that we know everything we need prior to installing FOSSBilling, let’s discuss the installation process.

Install Nginx Web Server

We will start by installing the Nginx web server. Before that, it’s good practice to update your system. Update your system with this command:

$ sudo apt update

Then install Nginx with this command:

$ sudo apt install nginx


install nginx

After the installation, you can verify if it’s working. To do that, run any of these commands:

$ sudo systemctl is-enabled nginx
$ sudo systemctl status nginx


nginx test

Both commands show that it’s working properly. Press “Q” to quit the screen.

Install and Configure MariaDB Server

In this step, we will create our Database server. For that, we chose MariaDB. To install MariaDB, run this command:

$ sudo apt install mariadb-server


install mariadb

In the same way, you can check if MariaDB is running properly using these commands:

$ sudo systemctl is-enabled mariadb
$ sudo systemctl status mariadb


mariadb test

After a successful installation, we now need to secure it. For that, run this command:

$ sudo mariadb-secure-installation


mariadb setup

Since this is a fresh install, there’ll be no root password. So press “Enter” to continue. Now you will go through some configuration questions. Read them and answer each question carefully. You can also follow our configuration.

mariadb setup
mariadb setup

Once done securing the database. Now create a database for FOSSBilling. Start the process with this command:

$ sudo mariadb -u root -p

You’ll be asked for a password. Write the one you created, or press “Enter” if you didn’t make any. We need to create a database and grant privileges to the user. To do that, enter these commands into the MariaDB menu:

> CREATE DATABASE fossbillingdistroid;
> CREATE USER [email protected] IDENTIFIED BY '123456';
> GRANT ALL ON fossbillingdistroid.* TO [email protected] WITH GRANT OPTION;


mariadb setup

Of course, use your own database name, user name, and password. Once done, type ‘quit’.

Install and Configure PHP-FPM 8.2

FOSSBilling requires PHP 8 or higher. We’ll be dealing with that aspect in this step. First, install the necessary dependencies with this command:

$ sudo apt install ca-certificates gnupg2 apt-transport-https software-properties-common


install php dependencies

Next, download the GPG key for the PHP repository with this command:

$ wget -O /etc/apt/trusted.gpg.d/php.gpg 


install php

Then add the PHP repository to the list using this command:

$ echo "deb $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list


install php

After adding that, update the package list using this command:

$ sudo apt update

Now install PHP on your Debian system with this command:

$ sudo apt install php8.2


install php

Then install the fpm extension with this command:

$ sudo apt install php8.2-fpm


install php

After that, install some other required PHP extensions with this command:

$ sudo apt install libcurl4-openssl-dev php8.2-{cli,zip,mysql,curl,mbstring,common, xml}


php extension

Now we can go to the main step and start downloading and installing FOSSBilling.

Download FOSSBilling

We will download the software in the ‘/var/www/fossbilling’ directory. So create the directory and go into it with these commands:

$ mkdir /var/www/fossbilling
$ cd /var/www/fossbilling


mkdir for fossbilling

Download the installation ZIP file with this command:

$ sudo curl -L --output


How to Install FOSSBilling with Nginx on Debian 11

Now unzip the file and change its ownership with the below commands:

$ sudo unzip
$ sudo chown -R www-data:www-data /var/www/fossbilling


How to Install FOSSBilling with Nginx on Debian 11

If this is done, then we can start configuring the web server that we will use for FOSSBilling

Set up Nginx Server Block

Use a text editor (we’re using nano) to create a server configuration file for FOSSBilling. For nano, you need to input this command:

$ sudo nano /etc/nginx/sites-available/fossbilling

Now enter this configuration:

server {
listen 80;

    set $root_path '/var/www/fossbilling';

    server_name localhost;

    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 .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/phpx.x-fpm.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;



Remember to use your own domain name. Save the file and exit. Now activate the server block with these commands:

$ sudo ln -s /etc/nginx/sites-available/fossbilling /etc/nginx/sites-enabled/
$ sudo nginx -t


How to Install FOSSBilling with Nginx on Debian 11

You should see a successful message as the output. Finally, restart Nginx with this command:

$ sudo systemctl restart nginx

Install FOSSBilling

Now it’s time to start installing FOSSBilling. Go to the registered domain to install FOSSBilling. So if you chose as your domain, go to the browser and enter it into the URL.

In the Preparation screen, all your system details will be verified. If everything went well, you should see green colored ‘ok’ written beside each item. 

In the Database tab, you enter all the credentials you used when creating the MariaDB database and press ‘Next’. In the Account and Currency window, enter your admin name, email, password, and currency. Then again, press ‘Next’.

After the installation, you should see a congratulations message. Click ‘Finish’. You should see two options—Client area and Admin area. If you go to the client area, you should see the following screen:

fossbilling client area

The admin area will take you to the login page.

fossbilling login

After logging in, you will be brought to the administration dashboard.

fossbilling admin dashboad

And that takes care of installing FOSSBilling on Debian.

Final Thoughts

This guide shows you how to install FOSSBilling with Nginx on Debian 11. It’s a bit of a lengthy process and might seem technical. But if you follow our tutorial thoroughly, you should be able to do it in no time.

If this guide helped you, please share it.

Related Posts