Installing Invoice Ninja on CentOS 7 w/ NGINX & MariaDB – Part One

Invoice Ninja Logo


Invoice Ninja is a free and open source invoicing system. The site also provides invoicing through Software as a Service (SaaS). But, of course, it’s possible to install and configure the software on a private server, which is a better option for companies that find themselves juggling a large number of payments.

Invoice ninja boasts many great features, depending on the plan that you chooce: Free, Pro, or Enterprise. With the free option, the following features are included:

  • create and email invoices with one click;
  • create recurring invoicing;
  • 45+ payment gateways supported;
  • accept deposits and partial payments;
  • auto-reminder emails for invoice payments;
  • shows payments in PDF files;

and more!

In this two-parts tutorial we will look at the process of installing and configuring Invoice Ninja on a server with CentOS 7 and NGINX.
In Part One, we’ll configure the system with required dependencies, and in the next we’ll work through the detailed installation of Invoice Ninja.

Install and configure NGINX

If not present, install the EPEL repository:

# yum install epel-release

Next, install NGINX:

# yum install nginx

Start and enable it to run at boot time:

# systemctl start nginx
# systemctl enable nginx

Check that NGINX is listening on port 80:

# netstat -plntu | grep 80

The output should be the following one:

tcp        0      0    *               LISTEN      3035/nginx: master  
tcp6       0      0 :::80                   :::*                    LISTEN      3035/nginx: master


Install MariaDB

Install MariaDB Server with



# yum install mariadb-server

Then, run it:

# systemctl start mariadb
# systemctl enable mariadb

Set up its root account:

# mysql_secure_installation
Set root password? [Y/n] 
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

Remove anonymous users? [Y/n] 
 ... Success!

Disallow root login remotely? [Y/n] 
 ... Success!

Remove test database and access to it? [Y/n] 
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reload privilege tables now? [Y/n] 
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

After that, start the MariaDB shell:

# mysql -u root -p

Create new database (ininjadb) and user (ininjausr):

MariaDB [(none)]> CREATE DATABASE ininjadb;
Query OK, 1 row affected (0.01 sec)

MariaDB [(none)]> CREATE USER ininjausr@localhost IDENTIFIED BY 'usr_strong_password';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON ininjadb.* TO ininjausr@localhost IDENTIFIED BY 'usr_strong_password';
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> EXIT;

MariaDB is now correctly configured.

Install PHP-FPM

Invoice Ninja requires PHP 5.9+, so let’s install PHP7-FPM. This is not available in the CentOS repositories, so add an external one:

# rpm -Uvh

Next, install PHP:

# yum install php70w-fpm php70w-cli php70w-pear php70w-gd php70w-xml php70w-mysql php70w-zip php70w-mbstring php70w-mcrypt php70w-curl php70w-gmp php70w-pdo

At the end, edit the PHP configuration file:

# $EDITOR /etc/php.ini

There, uncomment the


line, and change its value:


Save, exit, and edit the PHP-FPM configuration file:

# $EDITOR /etc/php-fpm.d/www.conf

Change user and group, as follows:

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx

Change “listen” line for using a socket:

listen = /var/run/php/php-fpm

Next, uncomment and edit as follow the lines:

listen.owner = nginx = nginx
listen.mode = 0660

Uncomment environment lines, starting at line 366:

; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

Save, exit and create a new PHP session directory:

# mkdir -p /var/lib/php/session

Change its owner to nginx user:

# chown -R nginx:nginx /var/lib/php/session

Create a new directory for the socket file, named as configured previously on



# mkdir -p /var/run/php
# chown -R nginx:nginx /var/run/php

Start and enable PHP:

# systemctl start php-fpm
# systemctl enable php-fpm

Check with


 that everything went well and is running smoothly:

# netstat -pxl | grep php
unix  2      [ ACC ]     STREAM     LISTENING     81417    5190/php-fpm: maste  /var/run/php/php-fpm


In this first part, we’ve looked at the process of configuring CentOS 7 and installing the dependencies required by Invoice Ninja. In the next tutorial, we’ll see how to complete the process of installing Invoice Ninja!