Self-hosted Free Invoicing App – FusionInvoice

Note that around the exact time of this article’s publication, FusionInvoice 2 was released as commercial software, and is based on Laravel instead of CodeIgniter like previous versions. It is, for all intents and purposes, a completely different application. This article focuses on the older but still fully functional version 1.3.4.


As a freelancer or a small business your time is better spent creating that next big project or meeting the client’s requirements than keeping track of invoices.

FusionInvoice is an open-source, self-hosted invoicing web application built for freelancers and small businesses. Although there are quite a few free online invoicing applications, none of them give you the privacy or the flexibility which FusionInvoice provides. Client management, dashboard and reports, recurring invoicing and invoice history are just few of its features.

FusionInvoice being an Open-Source project means that you can always change or add to its functionality as you need it or even install it on a private system, thus limiting the number of users who have access to your sensitive data.

Although the application is Open-Source, the developers considered that the community can better help the project by only providing their input and suggestions for features and enhancements they, as a community, would like to see in the project, but development should stay a closed team effort.

This may seem like a strange approach to open source a project, but it looks like it lets the team focus on keeping a constant pace in developing new features and bug fixing.

Software requirements

Since FusionInvoice version 1.3.4 is a CodeIgniter-based project, the basic requirements are quite simple:
- PHP 5.3 or newer
- MySQL 5.0 or newer
- Apache or Nginx server

Let’s check if your system meets these requirements.
Run the following command in your terminal to check the PHP version that is installed:

$ php -v

If PHP is properly installed you should receive an output similar to this one:

PHP 5.5.3-1ubuntu2.1 (cli) (built: Dec 12 2013 04:24:35) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

Now let’s check the MySQL version by running the command below in your MySQL prompt:

mysql> SHOW VARIABLES LIKE "%version%";

If the MySQL server is properly installed and running, you should now see an output similar to the one below.

+-------------------------+-------------------------+
| Variable_name           | Value                   |
+-------------------------+-------------------------+
| innodb_version          | 5.5.34                  |
| protocol_version        | 10                      |
| slave_type_conversions  |                         |
| version                 | 5.5.34-0ubuntu0.13.10.1 |
| version_comment         | (Ubuntu)                |
| version_compile_machine | x86_64                  |
| version_compile_os      | debian-linux-gnu        |
+-------------------------+-------------------------+

Depending on your server setup the version numbers might be different but the output should be similar.

Ok, since the requirements on this VM are met let’s proceed to the next section.

Download the FusionInvoice application

First, let’s create the folder where we would like to install FusionInvoice, by running the command below:

$ cd /var/www/
$ sudo mkdir -m 755 fusioninvoice

Note: I am assuming that you are on a *nix platform (if on Windows, please use Vagrant to set up a working environment), and are using the default Apache/Nginx configuration and have /var/www as your base document root folder. Otherwise, change the path to the one you’re using.

You can download version 1.3.4 from Github. After you do, unzip it into your websites folder (www as mentioned above).

Create the database

Now we need to create a database where FusionInvoice would store its data.
There are two ways to do this, command line or phpMyAdmin.
I personally recommend the command line if you are installing FusionInvoice on a production or world available server.

a) From the mysql prompt execute the following commands:

mysql> CREATE DATABASE `fusion_invoice`;
mysql> CREATE USER 'fusion_invoice'@'localhost' IDENTIFIED BY 'fusion_pass';
mysql> GRANT ALL PRIVILEGES ON `fusion_invoice`.* TO 'fusion_invoice'@'localhost' IDENTIFIED BY 'fusion_pass';

b) Using phpMyAdmin, go to the USERS tab and select Add user. In the new user form fill-in all the fields and make sure you check the Create database with same name and grant all privileges checkbox and phpMyAdmin will create the database for you.

**Note: Please make sure to take ALL necessary security precautions and adjust the new user’s permissions accordingly if you are installing the FusionInvoice application on world available server.

That’s it! We are now ready to run the FusionInvoice setup module.

Initial configuration of FusionInvoice

To start the setup process we need to access the /setup module from your preferred browser:

http://[domain-name]/[fusioninvoice]/index.php/setup

**Note: Depending on your server configuration the URL might be a bit different. The idea is that you need to send all your requests that do not map to a physical file to index.php in order to start the FusionInvoice application. If you do not know how to create a virtual host or redirect your requests to index.php you can find an optional step at the end of the article that will guide through this exact process.

In step 2, the FusionInvoice setup system is providing us with a list of files and folders which are required to be writable.

Let’s fix this by running the following commands from the terminal:

$ cd /var/www/fusioninvoice
$ chmod 777 -R uploads/
$ chmod 777 application/config/database.php 
$ chmod 777 -R application/helpers/mpdf/tmp/

If you refresh the page you should now see all the prerequisites to be properly set up.

In step 3 we have to provide FusionInvoice with the database server connection details.

If the connection is successful in the next 2 pages FusionInvoice will let you know that the database tables have been properly installed and upgraded.

Arriving at the last step you will be asked to create a base user, an administrator account.

Once this step is finished you will have successfully installed FusionInvoice on your system.

Now, you can log in and start creating those invoices :)

Create a virtual-host on your server

This optional step will guide you through the process of creating a basic virtual host on Apache or Nginx.

**Important note: Although many of the virtual host settings that are presented in this article are used also in production they are only a starting point and in no way should they be considered sufficient, from a security perspective, for a production server. Please make sure you’ve taken all the necessary precautions to secure your server.

a) Setting up an Apache virtual-host

First, let’s make sure Apache has the mod_rewrite module active. You can check that by running the following command:

$ apache2ctl -t -M

The above command will list all the modules loaded by the Apache2 server. If the mod_rewrite module is loaded you should see an entry like the following:
rewrite_module (shared)

If the above line is not present run the next command in your terminal to enable the module:

$ sudo a2enmod rewrite

Now that the mod_rewrite module is active we need to create a config file for our new host. You can do that by running the following command in your terminal:

$ sudo vim /etc/apache2/sites-available/fusion_invoice.dev.conf

Now copy the code below to your config file, and edit the paths to match yours:

    <VirtualHost *:80>
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/fusioninvoice

            ServerName fusion.invoice.dev #change this setting according to your domain name

            DirectoryIndex index.php

            <Directory /var/www/fusioninvoice>
                RewriteEngine On
                RewriteBase /

                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule ^(.*)$ index.php [QSA,L]
            </Directory>

            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>

Now save and close your editor and run the following command in your terminal:

$ sudo a2ensite fusion_invoice.dev.conf
$ sudo service apache2 restart

That is all. You can now use your new URL, fusion.invoice.dev, instead of localhost or the VM’s IP address.

b) Setting up a Nginx virtual-host

Let’s create the config file for our new virtual-host by running the following command in your terminal:

$ sudo vim /etc/nginx/sites-available/fusion_invoice.dev.conf

Now copy the code below to your config file, and edit the paths to match yours:

server {
    listen        80;

    server_name   fusion.invoice.dev; #change this setting according to your domain name

    root          /var/www/fusioninvoice; # path to fusioninvoice's install directory

    error_log     /var/log/nginx/fusion.error.log debug;

    access_log    /var/log/nginx/fusion.access.log;

    index         index.php;

    location ~ ^(.+\.php)(.*)$ {
      fastcgi_split_path_info  ^(.+\.php)(.*)$;
      fastcgi_pass       unix:/var/run/php5-fpm.sock;
      include            fastcgi_params;
      fastcgi_param      HTTPS off; #this is required for development mode
      fastcgi_param      PATH_INFO $fastcgi_path_info;
      fastcgi_param      SCRIPT_FILENAME $document_root/$fastcgi_script_name;
    }

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

Now that we created the config, on *nix systems you need to create a symbolic link from the file’s current location into /etc/nginx/sites-enabled folder in order for Nginx to load the new virtual-host.

You can create the symlink by running the next command in your terminal:

$ sudo ln -s /etc/nginx/sites-available/fusion_invoice.dev.conf  /etc/nginx/sites-enabled/fusion_invoice.dev.conf

Again, alter all paths to match yours. Now, let’s restart the Nginx server to load our new virtual-host config.

$ sudo service nginx restart

If all went well you should now be able to access your new virtual host using the server name instead of the machine’s IP address or localhost.

Remove the ‘index.php’ entry from the URL

Now that we have created a virtual host let’s also remove the index.php from the URL and have some nice, easy to remember URLs.
For that, we just need to open the config.php file, located at /var/www/fusioninvoice/application/config/, and edit the following line:

$config['index_page'] = 'index.php';

Now just delete the index.php value and save the file.

Conclusion

The abundance of features, the relatively low level of technical knowledge required to set up and manage the application along with an active community ready to help, make FusionInvoice a great tool for any freelancer or small-business owner who wants to spend the time on the project rather then on tracking invoices.

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

  • FusionInvoice

    Thanks for the write-up, but be aware that we are currently transitioning things over to version 2. As soon as DNS fully propagates, version 1.x won’t even be available for download any more.

    • http://www.bitfalls.com/ Bruno Skvorc

      Thanks for the heads up. Is there anyone I could talk to more directly? Please get in touch via bruno.skvorc@sitepoint.com or through +BrunoSkvorc

    • Taylor Ren

      Noticed this. The site is currently down. https is not working.

      • FusionInvoice

        Yeah, just gotta get the cert transferred over. Until then, you can use http.

        • Taylor Ren

          Considering that we are in a fast-pace age, the site transfer/upgrade is taking too long…

    • chzumbrunnen

      But gladly there are many forks available on GitHub.

  • https://www.raptor-editor.com/ Petah

    Its a bit sucky that they totally broke their site and are trying to remove all traces to the FOSS version :(

  • Roman

    It’s a pity that SQLite isn’t used more often instead of server-based DBMSs. SQLite would be perfect for this kind of application — doesn’t require setting anything up and is easy to back up.

    • Denis Rendler

      I totally agree, Roman. SQLite with PHP 5.4′s internal web server would have been a perfect fit.

      • Roman

        Seeing a comma in front of a name warms my heart. So few people know how to write correctly :)

  • Roman

    The link to Vagrant is invalid.

    • http://www.bitfalls.com/ Bruno Skvorc

      Thanks, fixed!

  • http://www.vemployee.com/hire-php-programmers.html jimmybrion

    I want to test this and suggest to my client.

  • http://www.bitfalls.com/ Bruno Skvorc

    Excellent, thanks!

  • http://www.bitfalls.com/ Bruno Skvorc

    Cheers, we’ll add it into the article

  • Jeff Jones

    Any idea why the fusioninvoice.com site has been down for so long? I’ve redesigned websites before. Never had one be completely offline for this kind of duration. Was it a hardware failure with poor backups? Seems like otherwise they could have at least kept the old site up and running until the 2.0 site was ready.

  • eenymeeny

    Just like to add my opinion that entirely removing the earlier version seems a bit contrary, given the original is open source? I have the old 1.3.4 version running on my local PC here (downloaded as a ZIP) and am now facing the task of understanding the system with zero documentation. Given that the developer would presumably like people familiar with the 1.3.x version to be interested in the 2.x project, this doesn’t seem the right way of going about things. an you imagine the uproar if Windows or Apple entirely removed their older versions before releasing a new one? Just my $0.02. I appreciate that the developer is free to do as he wishes with his code, but the approach just seems odd, that’s all.

    Well anyway, now off to work out a) if this thing has an API and b) how the import works.

  • http://keithmclaughlin.ie Keith McLaughlin

    So typical… as soon as they get any kind of recognition they move from open source to a paid product.

    • http://www.bitfalls.com/ Bruno Skvorc

      To be fair, the app has been out for a very long time. Our publication coinciding with their release of a paid version was entirely by accident. However, the approach they took to removing the old version is dubious, yes, like @eenymeeny:disqus said below