How to Install Invoice Ninja on Debian 12

Estimated reading: 5 minutes 649 views

Invoice Ninja is a free, open-source, self-hosted application for invoicing and billing customers. It is written in PHP with a Laravel framework. Invoice Ninja is specially designed for freelancers & businesses for invoicing, accepting payments, tracking expenses, creating proposals, and time tracking. It allows you to create and send invoices to clients with your own domain name and brand. Invoice Ninja supports 40+ payment gateways, including WePay, GoCardless, PayPal, Authorize.net, 2Checkout, and more.

In this post, we will guide you through the process of installing Invoice Ninja with Nginx on Debian 12.

Prerequisites

  • A fresh Debian 12 server
  • A valid domain name is pointed to your virtual private server
  • A root password configured on your server

Step 1 – Install LEMP Server

First, you will need to install Nginx, MariaDB, PHP, and other PHP extensions on your server. You can install all of them with the following command:

apt-get install nginx mariadb-server php php-zip php-bcmath php-fpm php-cli php-common php-curl php-gd php-mysql php-xml php-mbstring unzip -y

Once all the packages are installed, stop the Apache service, start the Nginx and MariaDB services if they are not already started.

systemctl stop apache2
systemctl start nginx
systemctl start mariadb

Step 2 – Create a Database

Next, you will need to create a database and a user for Invoice Ninja. First, log in to MariaDB with the following command:

mysql

Once connected, create a database and a user with the following command:

CREATE DATABASE greencloudninja;
GRANT ALL PRIVILEGES ON greencloudninja.* TO 'greencloudninja'@'localhost' IDENTIFIED BY 'Green@12345';

Next, flush the privileges and exit from MariaDB with the following command:

FLUSH PRIVILEGES;
EXIT;

Step 3 – Download Invoice Ninja

Next, download the latest version of Invoice Ninja with the following command:

wget https://github.com/invoiceninja/invoiceninja/releases/download/v5.11.72/invoiceninja.tar.gz

Once the download is completed, extract the downloaded file to the Nginx root directory:

cd /var/www/html
mv ~/invoiceninja.tar.gz /var/www/html/
tar -xvzf invoiceninja.tar.gz

Next, copy the example environment file.

cp .env.example .env

Next, change the ownership of the invoiceninja directory to www-data:

chown -R www-data:www-data /var/www/html/

Set proper permissions.

chmod -R 775 *

Step 4 – Configure Nginx for Invoice Ninja

Next, you will need to create an Nginx virtual host configuration file for Invoice Ninja.

You can create it with the following command:

nano /etc/nginx/conf.d/ninja.conf

Add the following lines:

server {
    listen 80;
    server_name greencloudinvoiceninja.example.net;

    root /var/www/html/public;
    index index.php index.html index.htm;

    client_max_body_size 20M;
    charset utf-8;

    access_log /var/log/nginx/invoiceninja.access.log;
    error_log /var/log/nginx/invoiceninja.error.log;

    gzip on;
    gzip_types application/javascript application/x-javascript text/javascript text/plain application/xml application/json;
    gzip_proxied no-cache no-store private expired auth;
    gzip_min_length 1000;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    if (!-e $request_filename) {
        rewrite ^(.+)$ /index.php?q= last;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }

}

Save and close the file, then verify the Nginx for any syntax errors with the following command:

nginx -t

Finally, restart the Nginx service to apply the changes:

systemctl restart nginx

Secure ownCloud with HTTPS

Install Certbot and the Nginx plugin.

apt install certbot python3-certbot-nginx -y

Generate and apply a TLS certificate.

certbot --nginx -d greencloudinvoiceninja.example.net

Certbot will automatically edit your Nginx config to enable HTTPS.

Step 5 – Access Invoice Ninja

Now access Invoice Ninja from the browser. Once done with installation, key in your server hostname (http://greencloudinvoiceninja.example.net) or (http://your_server_ip)on your browser to access Invoice Ninja and finish up the setup. You should see a page as below:

Then, input the database details and test database connectivity.

With a successful Database connection, proceed to create the first user account. Agree to the terms of service and privacy policy and click ‘submit’ at the bottom of the page. You should then be presented with a login page as below:

Provide your email address and password previously set to log in.

Then provide your company Name and preferred currency:

That’s it. You have successfully installed Invoice Ninja on Debian 12.

Visit the Settings / Company Details section to declare more relevant information: Website, Email, Address, etc. This information will be displayed on invoices sent to customers.

Connect to Stripe & PayPal

Invoice Ninja supports connecting to payment gateways such as Stripe and PayPal to help customers pay with payment cards directly from invoices generated by the system.
Go to Settings -> Payment Settings, select Add Gateway, choose Stripe or PayPal, and then enter the required information (API Keys) from your Stripe/PayPal account.

Create invoices and receive payments

1. Create a new invoice.

Go to Invoices and select Create Invoice.
Add customer information, services/products, and taxes (if any).
Customize the invoice as you wish (logo, color, terms).

Once done, click the Save button to save the invoice.

2. Send invoices to customers

You can send invoices to customers in two ways

Click the arrow button next to the Save button and select Email Invoice to email the invoice.
Right-click on the View in Portal line, select Copy Link, then send this link to customers via Zalo, Facebook, SMS, or other platforms.

3. Receive payment.

Customers can pay with Stripe/PayPal (if you have configured) after receiving the invoice email/portal link. After successful payment, the invoice will be automatically updated from Sent to Paid.

Conclusion

Congratulations! You have successfully installed and configured Invoice Ninja on Debian 12. You can now implement Invoice Ninja in your organization and start invoicing and billing customers with your VPS from Greencloud!

Share this Doc

How to Install Invoice Ninja on Debian 12

Or copy link

CONTENTS