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

This tutorial will be showing you how to install InvoiceNinja on Ubuntu 18.04 with Apache or Nginx web server. InvoiceNinja is an open source, self-hosted invoice software, a low-cost alternative to commercial online invoice platforms such as Freshbooks. InvoiceNinja provides hosted invoice service, but if you like to self host the software, you can follow the instructions below.

InvoiceNinja Features

  • With InvoiceNinja, you can send invoices to your clients by using your own domain name and brand.
  • Manage invoicing for multiple businesses all under one account.
  • Save time by automatically billing long-term clients with recurring invoices.
  • Easily create and send beautiful proposals to your customers.
  • Attach 3rd Party Files to Invoices.
  • Create Project Tasks & Track Time.
  • Organize and plan your client work with a visual project management tool.
  • Allow your clients to see all their transactions with you in one glance.
  • Zapier automation allows you to transfer data between your invoicing account and popular apps including Gmail, Google Sheets, QuickBooks Online, Slack, Pipeline, MailChimp, and hundreds more.
  • Request deposits & partial payments using the same invoice again and again.
  • Use a pre-written auto-reminder email sequence to remind clients your invoice needs to be paid.
  • Receive notifications when a client views and pays your invoice.
  • And many more


First, you need a Linux server with at least 512MB RAM. You can click this special link to get $100 free credit on DigitalOcean. (For new users only). If you are already a DigitalOcean user, then you can click this special link to get $50 free credit on Vultr (for new users only). Once you have an account at DigitalOcean or Vultr, install Ubuntu 18.04 on your server and follow the instructions below.

InvoiceNinja requires PHP and MySQL/MariaDB. To follow this tutorial, you should have already set up a LAMP stack or LEMP stack. If you haven’t already done so, please use one of the following guides.

And you also need a domain name, so your clients can see the invoice via your domain name. I registered my domain name at NameCheap because the price is low and they give whois privacy protection free for life.

Now let’s install InvoiceNinja.

Step 1: Download InvoiceNinja Install Zip File on Ubuntu 18.04 Server

Login into your Ubuntu 18.04 server via SSH. Then run the following command to download the latest version of InvoiceNinja zip file onto your server.

wget -O

Once downloaded, extract the archive with unzip.

sudo apt install unzip

sudo unzip -d /var/www/

The -d option specifies the target directory. InvoiceNinja web files will be extracted to /var/www/ninja. To better identify each directory, you can rename it to invoice-ninja.

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

Then we need to change the owner of this directory to www-data so that the web server can write to this directory.

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

We also need to 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

Log into MariaDB database server with the following command. Since MariaDB is now using unix_socket plugin to authentication user login, there’s no need to enter MariaDB root password. We just need to prefix the mysql command with sudo.

sudo mysql

Then create a database for Invoice Ninja. This tutorial names the database invoiceninja. You can use whatever name you like.

create database invoiceninja;

Create the database user. Again, you can use your preferred name for this user. Replace your-password with your preferred password.

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

Grant this user all privileges on the invoiceninja database.

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

Flush privileges and exit.

flush privileges;


Step 3: Setting Up Web Server

We can use Apache or Nginx web server.


If you prefer Apache, create a virtual host file for Invoice Ninja.

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

Put the following text into the file. Replace the red-colored text with your actual data. Don’t forget to set A record for the domain name. (Note that the web root is set to /var/www/invoice-ninja/public/, not /var/www/invoice-ninja/)

<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


Save and close the file. Then enable this virtual host.

sudo a2ensite invoice-ninja.conf

We need to enable the rewrite module.

sudo a2enmod rewrite

Restart Apache for the changes to take effect.

sudo systemctl restart apache2

Now visit and you will be redirected to the Invoice Ninja setup wizard page ( If you see the default Apache page instead of the setup wizard, then you need to disable the default virtual host.

sudo a2dissite 000-default.conf

And restart Apache.

Before entering any information in the setup wizard, we need to enable HTTPS.


If you prefer Nginx, create a invoice-ninja.conf file in /etc/nginx/conf.d/ directory.

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

Put the following text into the file. Replace the red-colored text with your actual data. Don’t forget to set A record for the domain name. (Note that the web root is set to /var/www/invoice-ninja/public/, not /var/www/invoice-ninja/)

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;

Save and close the file. Then test Nginx configuration.

sudo nginx -t

If the test is successful, reload Nginx for the changes to take effect.

sudo systemctl reload nginx

Now visit and you will be redirected to the Invoice Ninja setup wizard page ( Before entering any information in the setup wizard, we need to enable HTTPS.

Step 4: Enabling HTTPS

To encrypt the HTTP traffic, we can enable HTTPS by installing a free TLS certificate issued from Let’s Encrypt. Run the following command to install Let’s Encrypt client (certbot) on Ubuntu 18.04 server.

sudo apt install certbot

If you use Nginx, then you also need to install the Certbot Nginx plugin.

sudo apt install python3-certbot-nginx

Next, run the following command to obtain and install TLS certificate.

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

If you use Apache, install the Certbot Apache plugin.

sudo apt install python3-certbot-apache

And run this command to obtain 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: Add the Strict-Transport-Security header to every HTTP response. Forcing browser to always use TLS for the domain. Defends against SSL/TLS Stripping.
  • --staple-ocsp: Enables OCSP Stapling. A valid OCSP response is stapled to the certificate that the server offers during TLS.

The certificate should now be obtained and automatically installed.

invoice ninja ubuntu 18.04

Step 5: Install PHP Modules

Run the following commands to install PHP modules required or recommended by InvoiceNinja.

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

Then restart Apache. (If you use Nginx, you don’t need to restart Nginx.)

sudo systemctl restart apache2

If these modules are not installed, you will see the following error after login.

Whoops, looks like something went wrong.

Step 6: Finish Installation with the Setup Wizard

Now go to and enter the database information, SMTP settings and create an admin user. If you would like to use your own mail server to send emails to clients, please check out the following article to set up your own mail server.

invoice ninja ubuntu apache nginx

After creating the admin user, you can log into InvoiceNinja.

set up invoice ninja ubuntu server

Set Up Cron Jobs

We need to set up Cron jobs to send recurring invoices and email reminders. Edit the root user’s crontab file.

sudo crontab -e

Add the following lines at the end of this file.

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

Save and close the file. The two Cron jobs will run at 8 AM every day. You can also manually run a job like below.

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

Removing the Invoice Ninja branding

By default, your invoice will have the Invoice Ninja branding, you can purchase a white label license for $20/per year to remove the Invoice Ninja branding from the invoice and client portal. Go to settings -> Invoice Design, click the white-label link to purchase.


I hope this tutorial helped you install Invoice Ninja on Ubuntu 18.04 server. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care 🙂

Rate this tutorial
[Total: 2 Average: 5]

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

  • Mysterion
    10 months ago

    Thanks for the detailed guide:)

  • Thanks for this – I got there in the end.
    Do I need to install a mail server as well or is that optional?

  • hi
    I followed your instructions (including the installing LAMP Stack on 18.04) and everything went well right till the end.
    I installed a self assigned ssl certificate as I am running this as a localhost machine only via the local ip address.
    I tested the database connection and email test. both work okay.
    when I click submit on the final setup page, it comes up and says unable to connect/problem loading page.
    what am I doing wrong? please help

    • I would never use a self-signed certificate for an invoicing application, because Web browsers will tell visitors the web page is insecure, and do you expect visitors to pay you on an insecure web page?

      InvoicingNinja is supposed to run on a server with a real domain name and valid SSL certificate.

      • we are not using the server for external use. simply just using it for internal company invoicing and we will not be using any remote login from outside our network.

  • I guess this version of Invoice Ninja cannot support additional modules as it doesn’t use the contain the Composer portions, right?

  • Thank you so much!

    I rarely get Nginx working when I use these kind of directions but I got it working the first time around.

    You are the best. I’ll buy you a cup of coffee after I have closed my first sale.

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community ( for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB.
You can upload: image.