BoxBilling is a powerful and user-friendly billing software designed for both clients and sellers. It offers an intuitive interface and supports multiple payment gateways, making it an ideal solution for businesses of all sizes. In this guide, we will walk you through the step-by-step process of installing BoxBilling on a Debian 11 Bullseye server. By following these instructions, you will be able to set up BoxBilling with Nginx, PHP-FPM, and MariaDB, ensuring a seamless experience for your clients and efficient billing management for your business.
Prerequisites
Before we dive into the installation process, let’s make sure you have everything you need to get started. Here are the prerequisites for installing BoxBilling on Debian 11:
- A Debian 11 Bullseye server.
- A user with sudo root privileges.
- A domain name or sub-domain pointed to the server’s IP address (especially for production environments).
Installing and Configuring PHP
The first step in installing BoxBilling is to install and configure PHP-FPM on your Debian system. BoxBilling requires PHP-FPM 7.4 or higher, which is the default PHP version available in the Debian repository. Here’s how you can do it:
- Update the Debian package index by running the following command:
sudo apt update
- Once the repository is refreshed, install PHP-FPM along with all the additional extensions required for BoxBilling:
sudo apt install php-fpm php-cli php-common php-zip php-mysql php-gd php-intl php-curl php-imap php-mbstring php-xml php-json libpcre3 openssl git unzip -y
- After the installation is complete, open the ‘php.ini’ file using a text editor:
sudo nano /etc/php/7.4/fpm/php.ini sudo nano /etc/php/7.4/cli/php.ini
- Within the ‘php.ini’ file, modify the following options according to your server’s environment:
memory_limit = 512M max_execution_time = 360 date.timezone = [Your TimeZone]
- Save the file and exit the text editor.
- Restart the PHP-FPM service to apply the new configuration:
sudo systemctl restart php7.4-fpm
- Verify the status of the PHP-FPM service to ensure it is running:
sudo systemctl status php7.4-fpm
Installing Nginx and MariaDB
Next, we need to install the Nginx web server and MariaDB database, both of which are essential components for running BoxBilling. Here are the steps to install Nginx and MariaDB:
- Install Nginx and MariaDB on your Debian 11 server using the following command:
sudo apt install nginx-full mariadb-server -y
- Once the installation is complete, verify the status of the Nginx and MariaDB services:
sudo systemctl status nginx sudo systemctl status mariadb
Setting Up MariaDB Database
After installing MariaDB, it is recommended to set up a root password for added security. Follow these steps to secure your MariaDB installation:
- Run the ‘mysqlsecureinstallation’ command to initiate the setup process:
sudo mysql_secure_installation
- When prompted, enter the root password for MariaDB. If you haven’t set one yet, simply press ENTER to continue.
- Type ‘Y’ to switch the default authentication method for the root user to ‘unixsocketauthentication’.
- If you wish to change the root password, type ‘Y’ and follow the instructions to set a new password.
- Type ‘Y’ to remove the default anonymous user on MariaDB.
- Type ‘Y’ to disallow remote login for the root user.
- Type ‘Y’ to remove the default ‘test’ database and its privileges.
- Finally, type ‘Y’ to reload the table privileges on MariaDB.
Congratulations! You have successfully set up the root password for MariaDB and secured your installation.
Setting Up a New Database and User for BoxBilling
In this step, we will create a new database and user specifically for BoxBilling. This will ensure that all BoxBilling-related data is stored separately and securely. Here’s how you can do it:
- Log in to the MariaDB shell using the following command:
mysql -u root -p
- Once logged in, run the following queries to create a new database and user for BoxBilling:
CREATE DATABASE boxbilling; CREATE USER boxbilling@localhost IDENTIFIED BY 'dbpassBoxBilling'; GRANT ALL ON boxbilling.* TO boxbilling@localhost WITH GRANT OPTION; FLUSH PRIVILEGES;
- Type ‘exit’ to log out from the MariaDB shell.
Congratulations! You have created a new database and user for BoxBilling.
Downloading BoxBilling Source Code
Now that we have set up the necessary components, it’s time to download the BoxBilling source code. There are multiple ways to install BoxBilling, but we will download the latest stable version from the source code. Here’s how:
- Create a new web root directory for BoxBilling and navigate into it:
mkdir -p /var/www/boxbilling cd /var/www/boxbilling
- Use the ‘wget’ command to download the latest stable version of BoxBilling (v4.22) from GitHub:
wget https://github.com/boxbilling/boxbilling/releases/download/4.22.1.3/BoxBilling.zip
- Extract the downloaded file using the ‘unzip’ command:
unzip Boxbilling.zip
- Create two new directories, ‘cache’ and ‘upload’, within the ‘/var/www/boxbilling/’ directory:
mkdir -p /var/www/boxbilling/bb-data/{cache,uploads}
- Change the ownership of the ‘/var/www/boxbilling’ directory to the ‘www-data’ user and group:
sudo chown -R www-data:www-data /var/www/boxbilling
- Allow the ‘www-data’ user to write to the ‘cache’ and ‘upload’ directories:
sudo chmod u+rw /var/www/boxbilling/bb-data/{cache,uploads}
Great! You have successfully downloaded and prepared the BoxBilling source code for installation.
Configuring Nginx for BoxBilling
To ensure that BoxBilling runs smoothly, we need to configure Nginx with the appropriate server blocks. The server blocks will define how Nginx handles incoming requests for BoxBilling. Here’s how you can configure Nginx for BoxBilling:
- Move to the ‘/etc/nginx/sites-available’ directory and create a new server block configuration file:
cd /etc/nginx/sites-available nano boxbilling.conf
- Copy and paste the following configuration into the ‘boxbilling.conf’ file. Make sure to replace ‘billing.example.io’ with your own domain name, and update the SSL certificate paths if necessary:
server { listen 80; server_name billing.example.io; return 302 https://$server_name$request_uri; } server { listen 443 ssl http2; set $root_path '/var/www/boxbilling'; server_name billing.example.io; index index.html index.htm index.php; root $root_path; try_files $uri $uri/ @rewrite; sendfile off; ssl_certificate /etc/letsencrypt/live/billing.example.io/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/billing.example.io/privkey.pem; ssl_protocols TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384; ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0 ssl_session_timeout 10m; ssl_session_cache shared:SSL:10m; ssl_session_tickets off; # Requires nginx >= 1.5.9 # ssl_stapling on; # Requires nginx >= 1.3.7 # ssl_stapling_verify on; # Requires nginx => 1.3.7 resolver 8.8.8.8 8.8.4.4 valid=300s; resolver_timeout 5s; add_header X-Frame-Options DENY; add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; access_log /var/log/nginx/example.com.access.log; error_log /var/log/nginx/example.com.error.log; location @rewrite { rewrite ^/(.*)$ /index.php?_url=/$1; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; include fastcgi_params; fastcgi_intercept_errors on; } location ^~ /bb-uploads/ { } location ^~ /bb-data/ { deny all; } location ~* ^/(css|img|js|flv|swf|download)/(.+)$ { root $root_path; expires off; proxy_no_cache 1; proxy_cache_bypass 1; } location ~ /\.ht { deny all; } }
- Create a symbolic link to enable the server block configuration:
ln -s /etc/nginx/sites-available/boxbilling.conf /etc/nginx/sites-enabled/
- Verify the Nginx configuration for any syntax errors:
sudo nginx -t
- If the configuration is correct, restart the Nginx service to apply the changes:
sudo systemctl restart nginx
Fantastic! Nginx is now configured to handle BoxBilling requests.
Installing and Configuring BoxBilling
With all the necessary components in place, it’s time to install and configure BoxBilling. Here’s how you can do it:
- Open your web browser and enter your BoxBilling domain name in the address bar (e.g.,https://boxbilling.example.io/).
- On the BoxBilling installation page, make sure all the requirements are met (indicated by green checkmarks). If any requirements are not met, resolve them before proceeding with the installation.
- Check the “I agree” box for the license agreement and click the “NEXT” button.
- Provide the database information (database name, user, and password) for BoxBilling and click the “NEXT” button.
- Enter the desired admin user, email, and password for BoxBilling and click the “NEXT” button.
- After the installation is complete, click the “FINISH” button to finalize the setup process.
Congratulations! You have successfully installed BoxBilling on your Debian 11 server.
BoxBilling Post Installation
Now that you have completed the BoxBilling installation, there are a few additional steps to ensure a secure and optimized setup. Follow these steps to finalize the installation:
- Remove the ‘install’ directory from the BoxBilling installation:
rm -rf /var/www/boxbilling/install
- Change the permission of the ‘bb-config.php’ file to restrict write access to the ‘www-data’ user:
sudo chmod 644 /var/www/boxbilling/bb-config.php
- Create a new cronjob for the ‘www-data’ user to perform scheduled tasks for BoxBilling:
export EDITOR=nano sudo crontab -u www-data -e
- Add the following line to the cron file to run the BoxBilling cron script every 5 minutes:
*/5 * * * * php /var/www/boxbilling/bb-cron.php
- Save the cron file and exit the text editor.
Great! You have completed the post-installation steps for BoxBilling.
Logging in to the BoxBilling Admin Page
To access the BoxBilling admin page and start managing your billing system, follow these steps:
- Open your web browser and enter the URL path ‘/bb-admin’ after your BoxBilling domain (e.g.,https://boxbilling.example.io/bb-admin/).
- On the BoxBilling admin login page, enter your admin username and password.
- Click the “LOG ME IN” button to access the BoxBilling admin dashboard.
Congratulations! You are now logged in to the BoxBilling admin page and ready to manage your billing system.
Conclusion
In this comprehensive guide, we have covered the step-by-step process of installing BoxBilling on a Debian 11 Bullseye server. By following these instructions, you have successfully set up BoxBilling with Nginx, PHP-FPM, and MariaDB, ensuring a seamless experience for your clients and efficient billing management for your business. With BoxBilling, you can now centralize your purchase management and provide your clients with a user-friendly and reliable billing solution.
Shape.host is a leading provider of Linux SSD VPS hosting services. With our scalable and secure cloud hosting solutions, you can focus on growing your business while we take care of the technical aspects. Visit us at Shape.host to learn more about our services and how we can empower your business with efficient and reliable hosting solutions.