• Get In Touch
April 29, 2017

How to Install Invoice Ninja on Ubuntu 16.04

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

Invoice Ninja is a free and open source application for invoicing, time tracking, payments and billing customers.

You can easily create and send invoices from anywhere using Invoice Ninja. Invoice Ninja is written in PHP and build with Laravel Framework.

In this tutorial, we will learn how to install and configure Invoice Ninja on a Ubuntu 16.04 server.

Requirements

  • A server running Ubuntu 16.04.
  • A non root user with sudo privileges setup on your server.

Update the System

Before starting, it is recommended to update your system with the latest version. You can do this with the following command:

sudo apt-get update -y
sudo apt-get upgrade -y

Once your system is up to date, you can proceed to the next step.

Install LAMP Server

First, you will need to install Apache, PHP and MySQL server on your system. You can install them with the following command:

sudo apt-get install apache2 mysql-server php5 php5-mysql -y

Once the installation is completed, start Apache and MySQL service and enable them to start at boot with the following command:

sudo update-rc.d apache2 defaults
sudo update-rc.d mysql defaults

Once you have done, you can proceed to the next step.

Install Required Dependencies

Next, you will need to install some required dependencies on your server. You can install them with the following command:

sudo apt-get install php5-gd php5-curl php5-mcrypt git curl wget unzip -y

Next, enable mcrypt module with the following command:

sudo php5enmod mcrypt

Next, you will also need to install composer on your system. Composer is a dependency manager that can be used to install required PHP libraries on your system.

You can install composer by running the following command:

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

Once composer is installed, you can proceed to the next step.

Configure Database

Before configuring your database, you will need to secure it first. You can secure it by running the mysql_secure_installation script:

sudo mysql_secure_installation

Answer all the questions as shown below:

Set root password? [Y/n] n
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

Once MySQL is secured, log in to the MySQL shell and create a database for Invoice Ninja:

mysql -u root -p

Enter your root password when prompt, then create a database for Invoice Ninja. It is recommended to set secure password:

mysql>CREATE SCHEMAninjaDEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

Query OK, 1 row affected (0.00 sec)`

mysql>CREATE USER 'ninja'@'localhost' IDENTIFIED BY 'ninja';
Query OK, 1 row affected (0.00 sec)`

Next, grant all privileges with the following command:

mysql>GRANT ALL PRIVILEGES ONninja.* TO 'ninja'@'localhost';

Next, flush all privileges so that the privileges table will be reloaded by MySQL and we can use new credentials.:

mysql>FLUSH PRIVILEGES;
Query OK, 1 row affected (0.00 sec)

Then, exit from the MySQL shell:

mysql>exit;
Query OK, 1 row affected (0.00 sec)

Download Invoice Ninja

You can download the latest version of the Invoice Ninja from GitHub repository with the following command:

git clone https://github.com/hillelcoren/invoice-ninja.git ninja

Once the download is completed, move the ninja directory to the apache web root directory:

sudo mv ninja /var/www/html/

Next, change the directory to ninja and install framework using composer command:

cd /var/www/html/ninja/
sudo composer install

Next, give proper permission to the ninja directory:

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

Once you have done, you can proceed to the next step.

Configure Apache for Invoice Ninja

Next, you will need to create a new virtual host directive in Apache. You can do this by creating ninja.conf file inside /etc/apache2/sites-available/ directory:

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

Add the following lines:

<VirtualHost *:80>
 ServerAdmin admin@yourdomain.com
 DocumentRoot /var/www/html/ninja/public
 ServerName 192.168.15.189
 ServerAlias www.yourdomain.com
 <Directory /var/www/html/ninja/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
 </Directory>
 ErrorLog /var/log/httpd/ninja-error_log
 CustomLog /var/log/httpd/ninja-access_log common
</VirtualHost>

Save and close the file, then restart Apache web server so that the changes take place:

sudo /etc/init.d/apache2 restart

Next, enable rewrite module and virtual host by running the following command:

sudo a2enmode rewrite
sudo a2ensite ninja.conf

Next, you will need to enable the production environment for Invoice Ninja. You can do this with the following command:

cd /var/www/html/ninja
sudo cp bootstrap/environment.default.php bootstrap/environment.php

Once you are done, you can proceed to the next step.

Access Invoice Ninja

Once everything is configured, open your web browser and type the URL http://your-server-ip, you will be redirected to the database configuration page:

Here, provide the following information:

Driver : MySQL
Host : localhost
Database : ninja
Username : ninja
Password : ninja

Next, provide SMTP server information as per your need, then create administrator account, accept the term of services and click on the “Submit” button.

Congratulations! Invoice Ninja is successfully installed on your system. You can now easily deploy it in production environment. Feel free to comment me if you have any questions.

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

Share this Article!

Related Posts

Node.js Authentication – A Complete Guide with Passport and JWT

Node.js Authentication – A Complete Guide with Passport and JWT

Truth be told, it’s difficult for a web application that doesn’t have some kind of identification, even if you don’t see it as a security measure in and of itself. The Internet is a kind of lawless land, and even on free services like Google’s, authentication ensures that abuses will be avoided or at least […]

Node.js and MongoDB: How to Connect MongoDB With Node

Node.js and MongoDB: How to Connect MongoDB With Node

MongoDB is a document-oriented NoSQL database, which was born in 2007 in California as a service to be used within a larger project, but which soon became an independent and open-source product. It stores documents in JSON, a format based on JavaScript and simpler than XML, but still with good expressiveness. It is the dominant […]

Using MySQL with Node.js: A Complete Tutorial

Using MySQL with Node.js: A Complete Tutorial

Although data persistence is almost always a fundamental element of applications, Node.js has no native integration with databases. Everything is delegated to third-party libraries to be included manually, in addition to the standard APIs. Although MongoDB and other non-relational databases are the most common choice with Node because if you need to scale an application, […]

Node.Js Vs Django: Which Is the Best for Your Project

Node.Js Vs Django: Which Is the Best for Your Project

Django and NodeJs are two powerful technologies for web development, both have great functionality, versatile applications, and a great user interface. Both are open source and can be used for free. But which one fits your project best? NodeJs is based on JavaScript, while Django is written in Python. These are two equally popular technologies […]

Nodejs Vs PHP:  Which Works Best?

Nodejs Vs PHP: Which Works Best?

Before getting into the “battle” between Node.js and PHP we need to understand why the issue is still ongoing. It all started with the increased demand for smartphone applications, their success forcing developers to adapt to new back-end technologies that could handle a multitude of simultaneous requests. JavaScript has always been identified as a client-side […]