Installation

Server Requirements

Invoice Ninja has a few system requirements. Built on top of Laravel it requires a PHP and MySQL server at a minimum with the following version and extensions installed.

You need to setup this version completely from scratch. Do not attempt to overwrite your old version of Invoice Ninja (4.x.x) with this version as the two codebases are completely different.

On ubuntu this should be as simple as running:

sudo apt install php7.4-bcmath php7.4-gmp php7.4-fileinfo php7.4-gd php7.4-json php7.4-mbstring php7.4-pdo php7.4-xml php7.4-curl php7.4-zip php7.4-gmp php7.4-mysqlnd

Installing Invoice Ninja

Installing on CentOS 8 / Ubuntu 20.04 (Recommended)

Technically computers has a very helpful step by step guide on how to install Invoice Ninja v5 from scratch onto CentOS, you can access the guide here. If Ubuntu is more your flavour you can follow his awesome guide here

Installing on Arch

If Arch Linux is more your flavor, brackenhill-mob from our forum has a very thorough step by step installation guide here

Download pre built zip. (Advanced)

A prebuilt zip can be downloaded from our GitHub release page here. You will need to download the package which is appended with -release, download the file named invoiceninja.zip.

Unzip this file into the virtual host directory you have created.

Ensure the file permission have been set to the web server user. For example in Ubuntu this is www-data if you have configured a virtual host with a root directory of /var/www/html you would set the ownership like this.

sudo chown -R www-data:www-data /var/www/html
Web server configuration

A sample NGINX configuration is provided below, it assumes you have PHP 7.4 installed with the PHP FPM extension installed

server {

listen 80;
server_name invoiceninja.test;
root /var/www/invoiceninja/public;
index index.php index.html index.htm;
client_max_body_size 20M;

gzip on;
gzip_types      application/javascript application/x-javascript text/javascript text/plain application/xml application/json;
gzip_proxied    no-cache no-store private expired auth;
gzip_min_length 1000;

location / {
    try_files $uri $uri/ =404;
}

location ~* \.pdf$ {
    add_header Cache-Control no-store;
}

if (!-e $request_filename) {
    rewrite ^(.+)$ /index.php?q= last;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}

location ~ /\.ht {
    deny all;
}

}

Performance hint!

Enable gzip in your webserver configuration, this will dramatically improve the loading time of the application! Please see the above nginx configuration for a sample of how to load the components of the application with gzip.

Database server configuration

Create a database on your MySQL compatible server and add a user that has full access to the database, database configuration is out of the scope of this article, more information can be found here

Cron configuration

Ensure you set the scheduler under the web server user i.e. sudo -u www-data crontab -e

Invoice Ninja relies heavily on the Laravel Scheduler, for this to operate it requires that a cron job to be configured, edit your crontab and enter the following record.

* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

If you are using shared hosting, then you will need to add an additional parameter to the cron command which looks like this:

* * * * * cd /path/to/root/folder && /usr/bin/php -d register_argc_argv=On artisan schedule:run >> /dev/null 2>&1

Installation from git (Advanced)

For power users installing the app from Github can be done with the following steps

git clone https://github.com/invoiceninja/invoiceninja.git

git checkout v5-stable

composer install --no-dev -o

cp .env.example .env

php artisan key:generate

php artisan optimize

Final setup steps

Once you have configured your virtual host, create a database and point your browser to http://your.domain.com/setup - the setup process will check a number of system settings such as PDF generation, database and mail settings and also allow you to configure the first account on the system, click Submit and the app will setup your application and redirect you to the login page

Cron configuration

Invoice Ninja relies heavily on the Laravel Scheduler, for this to operate it requires that a cron job to be configured, edit your crontab and enter the following record

Ensure you set the scheduler under the web server user i.e. sudo -u www-data crontab -e

* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

Some Webservers require the Cronjob to end with > /dev/null 2>&1 instead of >> /dev/null 2>&1 for it to work. Also check if your Webserver Cronjob needs to be set with /private_html/ instead of /public_html/ within the path. And sometimes it's enough to put php instead of /opt/alt/php73/usr/bin/php in the cronjob scheduler command to execute.

If you still encounter errors, it may be helpful to temporarily remove >> /dev/null 2>&1 from the cron, this should output the cron to the cron.log

If you are having troubles with your crons, have a look at the troubleshooting section here

If you would like to improve the performance of your Invoice Ninja installation, then turning on the queue system will dramatically improve the performance of the application.

If you have root access to your system, then simply follow the Laravel guide to configure the supervisor service to start and restart your queue.

You will then need to update the QUEUE_CONNECTION variable in the .env file as follows:

QUEUE_CONNECTION=database

If you are on shared hosting, it is possible to get the queues working by defining a new cron with the following configuration:

*/5 * * * * cd  /path/to/root/folder && /usr/bin/php -d register_argc_argv=On artisan queue:work --stop-when-empty

This cron will start a queue worker every 5 minutes and run any jobs that are in the queue and then gracefully terminate itself. This means any emails / notification may be queued for a small period of time prior to executing. If this amount of delay is acceptable, it is a great way to get queue's working on shared hosting.

Shared Hosting

Server Requirements

We have tested Invoice Ninja v5 on shared hosting and can confirm that it does work. Softaculous has a one click installer which makes the entire setup process simple, however if you do not have Softaculous available it may still be possible to install Invoice Ninja. There are several checks you will need to do prior to confirming whether your Shared Host has the correctly enabled modules. Invoice Ninja relies on:

Without these modules, you will not be able to run Invoice Ninja. We do include some preflight checks of these modules in the Setup workflow, but it is best to check with your host that they support these modules. Some hosts choose to disable these modules as they classify them as security risks.

Database configuration

Create a MySQL compatible database in your shared host control panel along with a database user, record the database name, username and password as you'll need this later. Ensure your database user has full access to the database you've just created.

Upload release asset

Download the latest release from our Releases page. Note, you'll want to find the latest release which will contain 3 files, the one you need will be annotated as invoiceninja.zip.

Upload this file to your shared host, typically if your webhost uses the industry standard cPanel, you'll want to upload the invoiceninja.zip file to the public_html directory. Once the upload has completed, using the file manager unzip the file.

Run setup

Navigate to https://your.url.com/setup and fill in the form. The setup process will perform some pre flight checks and then attempt run the setup. If it has been successful you will be navigated to the Admin portal. If the setup fails for some reason, you'll be returned to the Setup screen with an error message, there may be additional errors reported in storage/logs/laravel.log that will provide more information where the setup has failed.

If you see a 404 webserver error and use sub.domain.com make sure to point the path for the subdomain towards the /public folder from the extracted invoiceninja.zip file, for example: /domains/domain.com/public_html/invoices2/public/

Add the cron job

Add the Laravel scheduler cron job, be sure to include the full path, for a cPanel host it should look like this:

* * * * * cd /path/to/root/folder && /usr/bin/php -d register_argc_argv=On artisan schedule:run >> /dev/null 2>&1

Installing Invoice Ninja (Docker)

If you prefer to use Docker, we have a dedicated repository with detailed instructions on how to get started HERE

Mail Configuration

When configuring your email, please ensure all of the fields are filled in. In particular you must include the MAIL_FROM_ADDRESS and MAIL_FROM_NAME to prevent errors such as

Address in mailbox given [ ] does not comply with RFC 2822, 3.6.2.

Here is a full example - using Gmail as an example.

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME="your_email_address@gmail.com"
MAIL_PASSWORD="your_password_dont_forget_the_quotes!"
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="your_email_address@gmail.com"
MAIL_FROM_NAME="Full Name With Double Quotes"

NOTE: if you are using SSL encryption the MAIL_PORT is 465. TLS encryption is on port 587.

Currency Conversion

Invoice Ninja supports Open Exchange for currency conversion. Open Exchange currently provides a free tier which is suitable for daily updates of the exchange rates. Simply insert a Open Exchange API key into your .env file to enable exchange rate updates:

OPENEXCHANGE_APP_ID=your_open_exchange_api_key_here

Make sure to update your cache afterwards:

php artisan optimize
Want to contribute? Edit this page on GitHub!