How to Install Invoice Ninja on Debian 9

How to Install Invoice Ninja on Debian 9

In this tutorial, we will show you how to install Invoice Ninja on Debian 9. Invoice Ninja is an open-source software application for invoicing and billing customers. It is built using PHP, on top of the Laravel framework. Some of the features include recurring invoices, creating tasks and projects, invoice designs, more than 40 payment options, and partial payments.

Looking to get some fully managed hosting for InvoiceNinja account? We offer complete migration, installation, optimization, and customization – 100% free of charge! Check out our premium affordable Linux VPS hosting packages and switch to a more secure, more efficient server with 24/7/265 amazing customer support today.

This guide should work on other Linux VPS systems as well but was tested and written for Debian 9 VPS. If you want to install Invoice on CentOS 7, follow this tutorial.

Step 1: Update your Debian server:

Log in to your VPS via SSH as a sudo user:

ssh userame@IP_Addressinv

Once you are logged in, issue the following commands to make sure all installed packages are up to date:

sudo apt-get update
sudo apt-get upgrade

Step 2: Install Nginx, MariaDB and PHP 7

To install Nginx, MariaDB PHP 7 and all ty nessesary PHP modules on your Debian server run the following command:

sudo apt-get install nginx php-fpm mysql-server php-cli php-common php-curl php-gd php-mysql php-xml php-mcrypt php-mbstring

When the MariaDB installation is complete, run the following command to secure your MariaDB installation:

sudo mysql_secure_installation

Step 3: Create a MariaDB database for Invoice Ninja

Login to the MariaDB console with the root account:

mysql -u root -p

Create a MariaDB database, user and grant permissions to the user using the following command:

MariaDB [(none)]> CREATE DATABASE ninja;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON ninja.* TO 'ninja'@'localhost' IDENTIFIED BY 'strongpassword';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q

Do not forget to replace ‘strongpassword’ with an actual strong password.

invoice ninja hosting

Step 4: Download Invoice Ninja

We can either download the archive file from the download.invoiceninja.comor check out the code from the GitHub Invoice Ninja repository. If you clone the GitHub repository you will need to use Composer to install the Invoice Ninja PHP dependencies while the archive file includes all required third-party PHP packages. In this post, we will install Invoice Ninja using the zip archive.

Download the latest stable version of the Invoice Ninja zip archive in the /tmp directory on your server with:

wget https://download.invoiceninja.com/ -O /tmp/invoice-ninja.zip

Once the download is completed extract the archive in the /var/www/html/ directory:

sudo unzip /tmp/invoice-ninja.zip -d /var/www/html/

Change the ownership to the www-data user with the following command:

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

Step 5: Configure Nginx to serve Invoice Ninja

Open your favorite text editor and create a new Nginx server block for the Invoice Ninja:

sudo nano /etc/nginx/sites-available/your_ninja_domain.com.conf
server {
    listen 80 default_server;
    server_name your_ninja_domain.com www.your_ninja_domain.com;

    root /var/www/html/ninja/public;

    index index.php;

    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/your_ninja_domain.com.access.log;
    error_log   /var/log/nginx/your_ninja_domain.com.error.log;

    sendfile off;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-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;
    }
}

Activate the server block by creating a symbolic link with the following command:

sudo ln -s /etc/nginx/sites-available/your_ninja_domain.com.conf  /etc/nginx/sites-enabled/your_ninja_domain.com.conf 

Test the Nginx configuration and if there are no errors restart the nginx service  using the following commands:

sudo nginx -t
sudo service nginx restart

invoice ninja hosting

Step 6: Install Invoice Ninja

Open http://your_ninja_domain.com/ in your favorite web browser and you will be redirected to the Invoice Ninja setup page.

From here you can finish the setup by entering the following information:

Application Settings

  • URL: your_ninja_domain.com
  • HTTPS: check the box if you have SSL installed
  • Debug: do not check the box

Database Connection

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
  • Driver: MySQL
  • Host: localhost
  • Database: ninja
  • Username: ninja
  • Password: strongpassword

Email Settings

Enter your email settings. You can use either you VPS SMTP or any supported third party SMTP provider.

User Details

Installing Invoice Ninja on Debian 9This is your Invoice Ninja administrator account. Enter your first name, last name, email address and password.
Finally select the I agree to the Terms of Service and Privacy Policy and click on the Submit button to finish the installation.

That’s it. You have successfully installed Invoice Ninja on Debian 9. For more information about how to manage your Invoice Ninja installation, please refer to the official Invoice Ninja documentation.


Install Invoice Ninja on Debian 9Of course, you don’t have to install Invoice Ninja on Debian 9, if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert system administrators to install Invoice Ninja on Debian 9 for you, using the LEMP stack or any other web hosting stack of your choice. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post, on how to install Invoice Ninja on Debian 9, please share it with your friends on the social networks using the buttons below or simply leave a comment in the comments section. Thanks.

4 thoughts on “How to Install Invoice Ninja on Debian 9”

  1. I’ve got this all set up with SendGrid as the SMTP provider.

    I’m struggling with how to set up the recurring and reminder crons

    And also the auto update crons using the script they provide (I don’t use composer, just used the zip file like you did here).

    Can you update the article to show how to add the 3 crons?

    Reply
    • To call the commands for recurring invoices and reminder emails, once a day, you can add the following in /etc/crontab:

      0 8 * * * /usr/local/bin/php /path/to/ninja/artisan ninja:send-invoices
      0 8 * * * /usr/local/bin/php /path/to/ninja/artisan ninja:send-reminders

      To update your application, you can simply download the latest version and copy the new code over the old one. Don’t forget to make a backup first.

      Reply

Leave a Comment