Step-by-Step Guide to Installing InvoicePlane with Nginx on Debian 9

InvoicePlane is a free and open-source invoicing application. You can find its source code on GitHub. This tutorial will guide you through installing InvoicePlane on a fresh Debian 9 (stretch) system.

Requirements

  • WebServer (Apache, NGINX). This tutorial will use Nginx.
  • MySQL version 5.5 or greater or the equivalent version of MariaDB.
  • PHP version 7.0, 7.1, or 7.2 with the following PHP extensions installed and activated:
    • php-gd
    • php-hash
    • php-json
    • php-mbstring
    • php-mcrypt
    • php-mysqli
    • php-openssl
    • php-recode
    • php-xmlrpc
    • php-zlib

Prerequisites

  • A server running Debian 9.
  • A non-root user with sudo privileges.

Initial Steps

Check your Debian version:

lsb_release -ds
# Debian GNU/Linux 9 (stretch)

Set up the timezone:

sudo dpkg-reconfigure tzdata

Update your operating system packages:

sudo apt update && sudo apt upgrade -y

Install some essential packages:

sudo apt install -y curl wget vim git unzip socat bash-completion apt-transport-https

Step 1 – Install PHP and Required PHP Extensions

InvoicePlane requires PHP version 7.0 or greater. Install PHP and the necessary PHP extensions:

sudo apt install -y php-cli php-fpm php-common php-gd php-json php-mbstring php-mysql php-xmlrpc php-recode

To show PHP compiled in modules, run:

php -m

ctype
curl
exif
fileinfo
. . .
. . .

Check the PHP version:

php --version

# PHP 7.0.9-1~deb10u1 (cli) (built: Sep 18 2019 10:33:23) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.0.9-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies

Start and enable PHP-FPM service:

sudo systemctl start php7.0-fpm.service
sudo systemctl enable php7.0-fpm.service

Step 2 – Install MariaDB

Install MariaDB:

sudo apt install -y mariadb-server

Check the MariaDB version:

mysql --version

Start and enable the MariaDB service:

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Run mysql_secure_installation to improve security and set the password for MariaDB root user:

sudo mysql_secure_installation

Answer the questions as follows:

Enter current password for root (enter for none):
Set root password? [Y/n]: Y
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

Log into the MariaDB shell as the root user:

mysql -u root -p
# Enter password

Create a MariaDB database and user:

CREATE DATABASE dbname;
GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

Exit from MariaDB shell:

quit

Replace dbname, username, and password with your own names.

Step 3 – Install NGINX

Install Nginx web server:

sudo apt install -y nginx

Check the NGINX version:

nginx -v
# nginx version: nginx/1.10.3

Start and enable the Nginx service:

sudo systemctl start nginx.service
sudo systemctl enable nginx.service

Configure NGINX for InvoicePlane:

sudo vim /etc/nginx/sites-available/invoiceplane.conf

Insert the following configuration:

server {
    listen 80;
    listen [::]:80;

    server_name example.com;

    root /var/www/InvoicePlane;

    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    }
}

Activate the new configuration:

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

Test the NGINX configuration:

sudo nginx -t

Reload NGINX:

sudo systemctl reload nginx.service

Step 4 – Install InvoicePlane

Download the latest stable version of InvoicePlane and extract it:

sudo mkdir -p /var/www
cd /var/www
sudo curl -O -J -L https://invoiceplane.com/download/v1.5.9
sudo unzip v1.5.9.zip
sudo rm v1.5.9.zip
sudo mv ip invoiceplane

Navigate to the installation directory:

cd /var/www/invoiceplane

Rename the configuration file:

sudo cp ipconfig.php.example ipconfig.php

Edit the file to set your URL:

sudo vim ipconfig.php
# Example
IP_URL=http://example.com

Change ownership of the directory:

sudo chown -R www-data:www-data /var/www/InvoicePlane

Edit the PHP configuration file to set the timezone:

sudo vim /etc/php/7.0/cli/php.ini

Add the following line:

date.timezone = Region/City

Restart PHP-FPM service:

sudo systemctl restart php7.0-fpm.service

Start the InvoicePlane installer in your web browser:

http://example.com/index.php/setup

After installation, you can log into InvoicePlane using your credentials. To secure the installation, you can set DISABLE_SETUP=true in ipconfig.php.

Step 5 – Complete The InvoicePlane Setup

With InvoicePlane installed and configured, access the web installation wizard:

Open your web browser and navigate to http://example.com. You will be guided through the setup process with step-by-step screen instructions.

InvoicePlane web installer

Frequently Asked Questions

  • What is InvoicePlane?InvoicePlane is an open-source invoicing software designed to provide users with a convenient way to manage billing and invoices.
  • Is InvoicePlane free?Yes, InvoicePlane is completely free to use and modify.
  • Can I run InvoicePlane on other Linux distributions?While this guide is for Debian 9, InvoicePlane can be installed on other Linux distributions with similar steps adjusted for the specific environment.
  • Where can I get support or assistance?Support can be obtained through the InvoicePlane community forums or from developers on GitHub.