Sep 25, 2020 6 min read

How to Install InvoiceNinja on Ubuntu 18.04 Server with Apache/Nginx

Install InvoiceNinja on Ubuntu 18.04. It is an open-source platform, usually used for managing billing and payments.

How to Install InvoiceNinja on Ubuntu 18.04 Server with Apache/Nginx
Table of Contents


Before we begin talking about how to install InvoiceNinja on Ubuntu 18.04, let’s briefly understand - What is InvoiceNinja?

InvoiceNinja is an open-source platform, usually used for billing, creating invoices and managing payments. It is specifically created to simplify financial interactions between freelancers and small to medium scale enterprises.

In this tutorial, you will install InvoiceNinja on Ubuntu 18.04. We will also address some FAQs related to the InvoiceNinja installation.


  • A Linux server with at least 512 MB RAM is required to install InvoiceNinja
  • Ubuntu 18.04 on your server
  • Set up a LAMP stack or LEMP stack before installation
  • A domain name so your clients can view your invoices under your domain name

Step 1 - Download and Install InvoiceNinja

1) First of all, login to your Ubuntu 18.04 server through SSH. After that, run the following command to download the updated compressed version of InvoiceNinja.

wget -O

2) Then use unzip to extract the archive.

sudo apt install unzip 

sudo unzip -d /var/www/

3) The target directory is indicated by -d option. InvoiceNinja web files will be extracted to /var/www/ninja. For better identification of your directory, rename it to invoice-ninja using the following:

sudo mv /var/www/ninja /var/www/invoice-ninja

4) To enable webserver to write on the directory, change the owner of the directory to www-data using the following command:

sudo chown www-data:www-data /var/www/invoice-ninja/ -R

5) Then, you must change the permission of the storage directory.

sudo chmod 755 /var/www/invoice-ninja/storage/ -R

Step 2 - Create a Database and User in MariaDB

After completing the first step, login into your MariaDB database server using the following command:

sudo mysql

2) After that, create the InvoiceNinja database. In this tutorial, the database name invoiceninja has been used. You may use whichever name you prefer.

create database invoiceninja;

3) The next step is to create the database user. Use any name for the same. Replace "your-password" with any password which you prefer.

create user ninja@localhost identified by 'your-password';

4) Grant the above-created database user the privileges on your database using this:

grant all privileges on invoiceninja.* to ninja@localhost;

5) Lastly, flush privileges and then exit.

flush privileges; 


Step 3 - Setting Up Web Server

1) Apache or Nginx web server can be used for this purpose.


1) If you use Apache, then, to create a virtual host file for InvoiceNinja, use the following:

sudo nano /etc/apache2/sites-available/invoice-ninja.conf

2) Type the following into the file. A domain name is required to be set beforehand.

<VirtualHost *:80>
    DocumentRoot /var/www/invoice-ninja/public

    <Directory /var/www/invoice-ninja/public>
       DirectoryIndex index.php
       Options +FollowSymLinks
       AllowOverride All
       Require all granted

    ErrorLog ${APACHE_LOG_DIR}/invoice-ninja.error.log
    CustomLog ${APACHE_LOG_DIR}/invoice-ninja.access.log combined


3) After saving and closing the file, enable virtual host.

sudo a2ensite invoice-ninja.conf

4) Then enable the rewrite module using the following command:

sudo a2enmod rewrite

5) You must restart Apache to effect the changes.

sudo systemctl restart apache2

6) After restarting, visit the link that will redirect you to the Invoice Ninja setup wizard page. In case, the default Apache page appears instead of the setup wizard page, then immediately disable the default virtual host using the following:

sudo a2dissite 000-default.conf

7) Restart Apache once again.

8) Before putting any information on the setup wizard, enable HTTPS.


1) If you use Nginx, then first and foremost, create an invoice-ninja.conf file in /etc/nginx/conf.d/ directory.

sudo nano /etc/nginx/conf.d/invoice-ninja.conf

2) Enter the below-given text into the file. Don't forget to replace with your own domain name.

server {
    listen      80;

    root /var/www/invoice-ninja/public/;
    index index.php index.html index.htm;
    charset utf-8;

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

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

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

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php7.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;

    location ~ /\.ht {
        deny all;

3) Then, you must save and close it. Test Nginx configuration using the following command:

sudo nginx -t

4) If successful, reload Nginx to apply the changes.

sudo systemctl reload nginx

5) After reloading, go to and you would be redirected to the InvoiceNinja setup wizard page Again, before putting any information on the setup wizard, enable HTTPS.

Step 4 - Enabling HTTPS

1) To encrypt the HTTP traffic, you could enable HTTPS by installing a  TLS certificate issued by Let’s Encrypt without incurring any charges. Use this command to install Let’s Encrypt client on Ubuntu 18.04 server.

sudo apt install certbot

2) In case you use Nginx, there is an additional step where you need to install the Certbot Nginx plugin using:

sudo apt install python3-certbot-nginx

3) Then, run this to successfully procure and install TLS certificate.

sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d

4) If you use Apache, use this to install the Certbot plugin.

sudo apt install python3-certbot-apache

5) The next step is to run this to successfully procure and install TLS certificate.

sudo certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d


  • --nginx: Use the Nginx plugin.
  • --apache: Use the Apache plugin.
  • --agree-tos: Agree to terms of service.
  • --redirect: Force HTTPS by 301 redirect.
  • --hsts: To every HTTP response, add the Strict-Transport-Security header. This will force the browser to use TLS for the domain. It protects against SSL/TLS Stripping.
  • --staple-ocsp: Allows OCSP Stapling. A valid OCSP response is stapled to the certificate that the server offers while TLS.

Step 5 - Install PHP Modules

1) Now, to install PHP modules required or recommended by InvoiceNinja, run the following command.

sudo apt install php-imagick php7.2-common php7.2-gd php7.2-json php7.2-curl php7.2-zip php7.2-xml php7.2-mbstring php7.2-bz2 php7.2-intl php7.2-gmp

2) Restart Apache. (If you use Nginx, you don't have to restart it)

sudo systemctl restart apache2

3) The following error will appear if the modules are not installed properly.

Whoops, looks like something went wrong.

Step 6 - Finish Installation using the Setup Wizard

1) Next step is to visit and put the information of database, SMTP settings and create an admin user.

invoice ninja ubuntu apache nginx

2) If you are using your server, you can select either of these drivers: SMTP and Sendmail.

  • Choose SMTP if you operate a mail server and InvoiceNinja on two different hosts.
  • Choose Sendmail if they run on the same host.

If you use SMTP, use these settings similar to:

  • host:  port: 587   Encryption: TLS. And enter your username and password.

If you choose Sendmail, then use something like this:

  • host:   port: 25    Encryption: none.  You don’t need to enter a username or password.

3) Login to InvoiceNinja after generating admin user.

set up invoice ninja ubuntu server

Step 7 - Set Up Cron Jobs

1) Cron jobs are to be setup for sending recurring invoices and repeated emails. Start by editing the crontab file of root user.

sudo crontab -e

2) Put this at the very end of the file.

0 9 * * * /usr/bin/php7.2 /var/www/invoice-ninja/artisan ninja:send-invoices > /dev/null
0 9 * * * /usr/bin/php7.2 /var/www/invoice-ninja/artisan ninja:send-reminders > /dev/null

3) After putting this text, automatic Cron jobs will run at 9 AM each day. For manually running it, use this command.

sudo /usr/bin/php7.2 /var/www/invoice-ninja/artisan ninja:send-invoices

FAQs to Install InvoiceNinja on Ubuntu 18.04

1) What are partial payments?

Partial payments enable clients to partially pay the invoice at different intervals, instead of doing a full invoice payment in a one-time transaction. You could easily locate the “Partial” box at the top of an existing or new invoice. Just put the partial payment amount, and the live PDF will be modified accordingly. After the payment by the client of the partial amount, the invoice will be updated by itself which will show the remaining balance due.

2) How do I convert a quote to an invoice?

In the Quote section, select a quote from your quote library, locate the “Action” drop-down on the far right, and select “Convert to Invoice”.

3) How do I apply a credit to a payment?

When you generate a new invoice and select an existing client with credit, on the “Enter Payment” page you can choose “Apply Credit”.


We hope this detailed guide helped you understand how to install InvoiceNinja on Ubuntu 18.04 server. To learn more about InvoiceNinja, check out the official InvoiceNinja  Installation Document.

If you have any queries, please leave a comment below and we’ll be happy to respond to them for sure.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.