How to Install InvoicePlane with Nginx on Debian 9

InvoicePlane is a free and open-source invoicing application. Its source code can be found on this Github. This tutorial will show you how to install 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 (software). That is an essential first step because it ensures you have the latest updates and security fixes for your operating system's default software packages:

sudo apt update && sudo apt upgrade -y

Install some essential packages that are necessary for basic administration of the Debian operating system:

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

Step 1 - Install PHP and required PHP extensions

InvoicePlane web application requires PHP version 7.0 or greater.

Install PHP, as well as 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, you can 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 MariaDB service:

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

Run mysql_secure installation script to improve MariaDB security and set the password for MariaDB root user:

sudo mysql_secure_installation

Answer all the questions as shown below:

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 MariaDB shell as the user root:

mysql -u root -p
# Enter password

Create a MariaDB database and user that you will use for your installation of InvoicePlane, and remember the credentials:

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

Exit from MariaDB shell:

quit

Replace dbnameusername, and password with your own names.

Step 3 - Install NGINX

Install Nginx webserver:

sudo apt install -y nginx

Check the NGINX version:

nginx -v
# nginx version: nginx/1.10.3

Start and enable Nginx service:

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

Configure NGINX for InvoicePlane. Run sudo vim /etc/nginx/sites-available/invoiceplane.conf and populate the file with 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 invoiceplane.conf configuration by linking the file to the sites-enabled directory:

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 the archive:

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 /var/www/invoiceplane directory:

cd /var/www/invoiceplane

Make a copy of the ipconfig.php.example file and rename the copy to ipconfig.php:

sudo cp ipconfig.php.example ipconfig.php

Open the ipconfig.php file and add your URL in it:

sudo vim ipconfig.php
# Something like this
IP_URL=http://example.com

Change ownership of the /var/www/invoiceplane directory to www-data:

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

Run sudo vim /etc/php.ini and set date.timezone:

date.timezone = Region/City

Restart the PHP-FPM service:

sudo systemctl restart php7.0-fpm.service

Run the InvoicePlane installer from your web browser and follow the instructions:

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

Once the installation has finished, you may log into InvoicePlane using the email address and password you have chosen during the installation.

If you want to secure your installation, you may disable the setup. To do so, replace the DISABLE_SETUP=false line with DISABLE_SETUP=true in your ipconfig.php file.

Step 5 - Complete the InvoicePlane setup

InvoicePlane is now installed and configured, it's time to access its web installation wizard.

Open your web browser and type the URL http://example.com. You will be redirected to the following page:

InvoicePlane web installer

Now, click on the Setup button. You should see the following page:

Choose language

Next, choose the language and click on the Continue button. You should see the following page:

Check system requirements

Next, click on the Continue button. You should see the following page:

Database details

Here, provide your database details and click on the Try Again button. You should see the following page:

Database connection successful

Now, click on the Continue button. You should see the following page:

Create user account

Now, click on the Continue button. You should see the following page:

InvoicePlane installation complete

Now, provide all the required details, then click on the Continue button. Once the installation is completed, you should see the following page:

Login to InvoicePlane

Now, click on the Login button to access InvoicePlane administration.

Share this page:

1 Comment(s)