This is an old revision of the document!


Install Invoice Ninja on Debian Jessie (8) with Nginx

Invoice Ninja is a free, open-source solution for invoicing and billing customers and it’s based on Laravel 4.1 framework. It can be installed on a LAMP/LEMP system. We are going to follow this installation guide for Debian 7 and apply it to a Debian 8 VM.

We assume to have a base VM with Debian 8 along with the VirtualBox Guest Additions already available, which we'll clone from the VirtualBox GUI as our starting point.

Once your clone is complete, launch it from the VirtualBox GUI and log into it from a terminal (our VM can be accessed from local ip 172.20.20.10), and upgrade the system so everything is up to date:

> ssh root@172.20.20.10
> apt-get update
> apt-get upgrade


During deployment of the Ninja Invoice system, we'll need a few extra packages, let's get them installed:

> apt-get install python-software-properties git curl openssl nano


MariaDB is an open source fork, by the original main developer of MySQL Monty Widenius, of the MySQL code that is now a property of Oracle. So we'll use MariaDB instead of MySQL.

> apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
> nano /etc/apt/sources.list.d/mariadb-10.1.list

PASTE:
deb http://mirror.jmu.edu/pub/mariadb/repo/10.1/debian jessie main

> apt-get update
> apt-get install mariadb-server
> mysql_secure_installation

Our MariaDB server is now ready to be used.


Create Database and User for Invoice Ninja

We need to create a database for our Invoice Ninja instance, as well as a specific user with privileges to manage it.

> mysql -uroot -p
> MariaDB [(none)]> CREATE DATABASE ininja;
> MariaDB [(none)]> GRANT ALL PRIVILEGES ON ininja.* TO '<ininja-user>'@'localhost' IDENTIFIED BY '<ininja-user_passwd>';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q

Don't forget to substitute <ininja-user> and <ininja-user_passwd> with the values that fit your needs.



All required packages are available straight from the Debian Jessie repositories:

> apt-get install nginx php5-fpm php5-cli php5-mcrypt php5-gd php5-curl
> php5enmod mcrypt

Install Composer

Composer is a dependency manager for PHP with which you can install packages. Composer will pull in all the required libraries and dependencies that you need for your project.

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


The install location of your Invoice Ninja instance can be freely chosen. Although, as the default Nginx web page is located in /var/www/html, we'll install it in /var/www/ininja/.
To keep things clear, we'll also create a specific user that we'll call ininja, we're gonna use it for the install procedure:

> adduser ininja
> mkdir /var/www/ininja
> chown -R ininja:ininja /var/www/ininja
[ SWITCH TO ininja USER ]
> su ininja
> git clone https://github.com/hillelcoren/invoice-ninja.git /var/www/ininja
> cd /var/www/ininja
> composer install [--no-dev -o]

The composer install process will install all of the project's dependencies, but it will pause halfway because the public download limit of Github will be reached, you'll need to have a Github account to obtain a token using the link that will be displayed in the terminal.

The --no-dev option might be used to specify not to install the dev packages of the project, those that are referenced in the require-dev section of the composer.json file.

The -o option means “dumping the autoloader” and has yet to be clarified here.

Composer will create a new vendor directory where all its files will be stored.