An invoice makes one of the most fundamental documents for any business. It is used to tell which goods or services have been rendered and how much to pay for. It provides a method through which individuals can make formal payment requests.
There are several invoicing solutions in the market today. Most small and growing businesses rely on open-source invoicing systems to run. The major benefit of this is that it costs nothing, therefore, minimizing the operational costs. The most popular invoicing systems are invoice Plane, Invoice Ninja, Ledgersmb, Dolibarr, Crater App e.t.c.
In this guide, we will learn how to install Invoice Ninja 5 on Ubuntu 22.04.
What is Invoice Ninja?
Invoice Ninja is one of the widely used open-source alternatives to commercial invoicing solutions such as Freshbooks. Invoice Ninja is a self-hosted invoice software for freelancers & businesses. It allows users to make and accept payments, track expenses, and create proposals and time tasks.
With Invoice Ninja users are able to perform the following:
- Create Project Tasks and Track Time, so you can get rid of third-party time trackers like clockify.me.
- Use a pre-written auto-reminder email sequence to remind clients your invoice needs to be paid.
- Get notifications when a client views and pays your invoice.
- Request deposits & partial payments using the same invoice again and again.
- Easily create and send beautiful proposals to your customers.
- Save time by automatically billing long-term clients with recurring invoices.
- Manage invoices for multiple businesses all under one account.
- Send invoices to your clients by using your own domain name and brand.
- Zapier automation allows you to transfer data between your invoicing account and popular apps including Gmail, QuickBooks Online, Google Sheets, Slack, Pipeline, MailChimp, and hundreds more.
- Allow your clients to see all their transactions with you in one glance.
- Attach 3rd Party Files to Invoices.
Today, we will install Invoice Ninja 5 which has the following added features:
- Expanded Payments Features: with multiple payment gateways supported per account, the ability to overpay/underpay an invoice and support for applying one payment across multiple invoices.
- Expanded Tasks & Projects: here we have the ability to attach documents to timed tasks and specify the rate on the task itself added.
- Invoices sent from your Gmail Account: Users are able to send invoices, quotes, & payment reminders via Gmail.
- New “Statuses” added to the “Invoice Life-cycle”: to meet a range of global accounting needs; Cancelled Invoice, Reversed Invoice and Restored Invoice have been added.
- Create Group Settings: this allows users to add or remove clients from different “Groups” to control custom settings at a ‘group’ level. They are also able to show different company logos & contact details to different client groups.
Let’s dive in!
How To Install Invoice Ninja on Ubuntu 22.04
This guide works best if you have the following:
- Ubuntu 22.04 running
- sudo access
- A domain name pointed to your IP
First, update your system and the available packages to their latest available versions:
sudo apt update && sudo apt upgrade -y
[ -f /var/run/reboot-required ] && sudo reboot -f
Install the required packages:
sudo apt install software-properties-common apt-transport-https ca-certificates gnupg2 vim -y
Set the hostname for your system.
sudo hostnamectl set-hostname invoiceninja.geeksforgeeks.org
Ensure that you have added this to the hosts file:
$ sudo vim /etc/hosts
192.168.205.22 invoiceninja.geeksforgeeks.org invoiceninja
#1. Install LAMP Stack on Ubuntu22.04
The LAMP consists of the Apache web server, PHP, and MariaDB database. These packages can be installed on our Ubuntu system using the below commands.
Install Apache and MariaDB
sudo apt install apache2 mariadb-server mariadb-client
Invoice Ninja 5 is currently compatible with PHP 8.1 which is provided by the default Ubuntu 22.04 repositories, we need to add no extra repository to install it.
sudo apt install php-{fpm,soap,bcmath,common,imagick,mysql,gmp,curl,intl,mbstring,xmlrpc,gd,xml,cli,zip,bz2} libapache2-mod-php
Once complete, check the version:
$ php -v
PHP 8.1.2-1ubuntu2.8 (cli) (built: Nov 2 2022 13:35:25) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
with Zend OPcache v8.1.2-1ubuntu2.8, Copyright (c), by Zend Technologies
Ensure that PHP-FPM is running:
$ systemctl status php*-fpm.service
● php8.1-fpm.service - The PHP 8.1 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php8.1-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-11-18 13:28:27 EAT; 41s ago
Docs: man:php-fpm8.1(8)
Process: 18793 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/8.1/fpm/pool.d/www.conf 81 (code=exited, status=0/SUCCESS)
Main PID: 18790 (php-fpm8.1)
Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
Tasks: 3 (limit: 4629)
Memory: 10.6M
CPU: 55ms
CGroup: /system.slice/php8.1-fpm.service
├─18790 "php-fpm: master process (/etc/php/8.1/fpm/php-fpm.conf)" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─18791 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ">
└─18792 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ">
Nov 18 13:28:27 invoiceninja.geeksforgeeks.org systemd[1]: Starting The PHP 8.1 FastCGI Process Manager...
Nov 18 13:28:27 invoiceninja.geeksforgeeks.org systemd[1]: Started The PHP 8.1 FastCGI Process Manager.
#2. Configure the Invoice Ninja 5 Database
We have the MariaDB server installed. Before we proceed, we need to start and enable the service:
sudo systemctl enable --now mariadb
Secure the installation:
sudo mysql_secure_installation
Proceed as shown below:
Enter current password for root (enter for none): Press Enter
....
Switch to unix_socket authentication [Y/n] y
.......
Change the root password? [Y/n] y
New password: Enter Password
Re-enter new password: Re-Enter Password
......
Remove anonymous users? [Y/n] y
...
Disallow root login remotely? [Y/n] y
...
...
Remove test database and access to it? [Y/n] y
....
Reload privilege tables now? [Y/n] y
.....
Thanks for using MariaDB!
Login to the shell using the created password above:
sudo mysql -u root -p
Now create a database for Invoice Ninja 5.
create database invoicedb;
create user invoice@localhost identified by 'Str0ngPassw0rd123';
grant all privileges on invoicedb.* to invoice@localhost;
flush privileges;
exit;
#3. Install Invoice Ninja 5 on Ubuntu 22.04
We will begin by downloading the latest archive from the Github Release page. This can also be done using wget as shown:
First, export the latest available version:
VER=$(curl -s https://api.github.com/repos/invoiceninja/invoiceninja/releases/latest|grep tag_name|cut -d '"' -f 4|sed 's/v//')
Now download the archive
wget https://github.com/invoiceninja/invoiceninja/releases/download/v${VER}/invoiceninja.zip
Once downloaded, extract it to the Apache root directory:
sudo unzip invoiceninja.zip -d /var/www/html/
Set the required permissions for the created directory:
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html
Now navigate to the directory:
cd /var/www/html
Copy the environment file to a backup file:
sudo cp .env.example .env
Edit the file:
sudo vim .env
Modify the below lines:
APP_URL=http://invoiceninja.example.com
DB_CONNECTION=mysql
MULTI_DB_ENABLED=false
DB_HOST=localhost
DB_DATABASE=invoicedb
DB_USERNAME=invoice
DB_PASSWORD=Str0ngPassw0rd123
DB_PORT=3306
Save and close the file, then set the correct ownership of the file:
sudo chown www-data:www-data /var/www/html/.env
Generate a unique app key for your InvoiceNinja installation.
$ sudo php /var/www/html/artisan key:generate
APPLICATION IN PRODUCTION.
Do you really wish to run this command? (yes/no) [no]
❯ yes
INFO Application key set successfully
Migrate the database using the command:
$ sudo php /var/www/html/artisan migrate:fresh --seed
APPLICATION IN PRODUCTION.
Do you really wish to run this command? (yes/no) [no]
❯ yes
Dropping all tables ................................................ 5ms DONE
INFO Preparing database.
Creating migration table .......................................... 64ms DONE
INFO Loading stored database schemas.
database/schema/mysql-schema.dump
.....
Database\Seeders\PaymentTypesSeeder ................................. RUNNING
Database\Seeders\PaymentTypesSeeder .......................... 126.68 ms DONE
Database\Seeders\GatewayTypesSeeder ................................. RUNNING
Database\Seeders\GatewayTypesSeeder ........................... 71.04 ms DONE
Database\Seeders\DateFormatsSeeder .................................. RUNNING
Database\Seeders\DateFormatsSeeder ........................... 130.51 ms DONE
Database\Seeders\DesignSeeder ....................................... RUNNING
Database\Seeders\DesignSeeder ................................ 255.06 ms DONE
#4. Configure Apache for Invoice Ninja 5
Now we need to configure the Apache webserver to be able to serve the Invoice Ninja 5 pages. This can be done by creating a virtualhost file as shown:
sudo vim /etc/apache2/sites-available/ninja.conf
In the file, add the below lines:
<VirtualHost *:80>
ServerName invoiceninja.geeksforgeeks.org
DocumentRoot /var/www/html/public
<Directory /var/www/html/public>
DirectoryIndex index.php
Options +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/invoice-ninja.error.log
CustomLog ${APACHE_LOG_DIR}/invoice-ninja.access.log combined
#Include /etc/apache2/conf-available/php8.1-fpm.conf
</VirtualHost>
In the file, replace the server name and PHP-FPM version correctly. Once the changes have been made, save the file and enable the site:
sudo a2ensite ninja.conf
Enable the required apache modules:
sudo a2enmod mpm_event proxy_fcgi setenvif
sudo a2enmod rewrite
Disable the default page:
sudo a2dissite 000-default.conf
For the changes made to apply, restart Apache:
sudo systemctl restart apache2
Verify that Apache is running correctly:
$ systemctl status apache2
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-11-18 13:35:12 EAT; 5s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 19270 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 19274 (apache2)
Tasks: 6 (limit: 4629)
Memory: 15.2M
CPU: 56ms
CGroup: /system.slice/apache2.service
├─19274 /usr/sbin/apache2 -k start
├─19275 /usr/sbin/apache2 -k start
├─19276 /usr/sbin/apache2 -k start
├─19277 /usr/sbin/apache2 -k start
├─19278 /usr/sbin/apache2 -k start
└─19279 /usr/sbin/apache2 -k start
Nov 18 13:35:12 invoiceninja.geeksforgeeks.org systemd[1]: Starting The Apache HTTP Server...
Nov 18 13:35:12 invoiceninja.geeksforgeeks.org systemd[1]: Started The Apache HTTP Server.
#5. (Optional) Enable HTTPS for Invoice Ninja 5
It is also possible to enable HTTPS for you either using SSL certificates. To generate free SSL certificates for your domain name, you can use Let’s Encrypt.
First, install the required packages:
sudo apt install python3-certbot-apache -y
Once installed, you can generate certificates for your site using the command:
certbot --apache -d invoiceninja.geeksforgeeks.org
In the above command, replace invoiceninja.geeksforgeeks.org with your Fully Qualified Domain Name.
You will be asked to accept the license terms and provide some details.
aving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2022.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Plugins selected: Authenticator apache, Installer apache
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for invoice.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/ninja-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/ninja-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/ninja-le-ssl.conf
Now allow HTTP traffic to be redirected to HTTPS
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
After this, you will have all the HTTP requests redirected to HTTPS.
#6. Access Invoice Ninja 5 on Ubuntu 22.04
Now we are set to access Invoice Ninja 5 on Ubuntu 22.04. This can be done from your favorite browser using the URL http://domain_name or https://http://domain_name
You will be redirected to the below page. Proceed and make the initial setup. Provide the URL for your site.
Once provided, click on Test PDF. If successful, proceed and configure the database as created earlier.
Once the details have been provided, test the connection.
On the next page, you can configure SMTP to be able to relay invoices using your GMAIL account. The required details are:
- Driver: SMTP
- Host: smtp.gmail.com
- Username: your Gmail username
- Password: your Gmail password
- Port: 587
- Encryption: STARTTLS
- Password: google-app-password
The google-app-password is a specific password for your application that can be generated from your Gmail account by navigating to Security > App passwords as shown.
Once you have clicked on App passwords, select the applications as Mail from the drop-down menu.
For the device, select Other (Custom name) and provide the name as invoice Ninja or any other name preferred.
Now generate the password for the application.
Once generated. you need to copy this password since it will be required in the below step.
Fill in the details as shown:
Once the details have been provided, test if the email is working. Finally, create an admin account for Invoice Ninja
You will then be redirected to the login page. Log in using the user creds created above:
Once authenticated, you be required to set your company name, theme, language, and currency.
Now you will be granted the below dashboard:
You are set to use Invoice Ninja 5. Just to demonstrate how to get started, we will create a sample client.
Once saved, the client will appear as shown.
Proceed and create a product/service
With the products and clients, you can now generate invoices
You can save the invoice, send it via email, print and view it e.t.c
#7. Schedule Email Reminders For Invoice Ninja
You can now configure Cron Jobs to send recurring invoices and email reminders. This can be done using the command:
sudo -u www-data crontab -e
In the file, add the below lines:
#InvoiceNinja
0 8 * * * /usr/bin/php /var/www/html/artisan ninja:send-recurring > /dev/null
0 8 * * * /usr/bin/php /var/www/html/artisan ninja:send-reminders > /dev/null
* * * * * /usr/bin/php /var/www/html/artisan schedule:run >> /dev/null 2>&1
Close the file and test if the Cron jobs can execute without any errors.
sudo /usr/bin/php /var/www/html/artisan schedule:run
Verdict
That marks the end of this detailed guide on how to invoice Ninja 5 on Ubuntu 22.04. We have only covered how to get started with invoice Ninja 5. There are many other functions you can perform using the Invoice Ninja 5. You are now free to explore them on your own.
See more: