How to Deploy Invoice Ninja - An Opensource Invoicing Application and Alternative to Freshbooks

Updated on 28 May, 2025
Learn how to deploy Invoice Ninja on Ubuntu 24.04 to manage invoices, payments, and financial tasks.
How to Deploy Invoice Ninja - An Opensource Invoicing Application and Alternative to Freshbooks header image

Invoice Ninja is an open-source invoicing application built on top of Laravel for sending invoices and tracking payments. It's a free and open-source alternative to accounting applications like Freshbooks and QuickBooks. You can use Invoice Ninja to perform financial management tasks, including income, expenses, payments, and time tracking.

In this article, you will deploy Invoice Ninja on an Ubuntu 24.04 based server. You will install Invoice Ninja and use the application to perform financial management tasks on the server.

Prerequisites

Before you begin:

  • Have access to an Ubuntu 24.04 instance as a non-root sudo user.
  • Create a domain A record pointing to the instance's IP address. For example, invoiceninja.example.com

Install Invoice Ninja

Invoice Ninja is based on Laravel, and you can install it using the latest release file or with Docker. Installing Invoice Ninja with a release file enables you to access the latest application features, while Docker allows you to run Invoice Ninja without any manual package installations. Use the following steps to install Invoice Ninja on your server.

  1. Update your package repository.

    console
    $ sudo apt update
    
  2. Allow HTTP and HTTPS traffic through your firewall.

    console
    $ sudo ufw allow http && sudo ufw allow https
    
Install Invoice Ninja Using the Latest Release File

Installing Invoice Ninja using the latest release file enables access to the latest application features and compatibility with other applications, such as web servers. Invoice Ninja requires PHP 8.3 with an active LAMP or LEMP stack to run with all required PHP extensions on your server. Use the following steps to install the LEMP stack and all the necessary dependencies to install Invoice Ninja.

Install Required Dependencies for Invoice Ninja

  1. Install Nginx, MySQL, and PHP.

    console
    $ sudo apt install nginx mysql-server php -y
    
  2. Verify the installed PHP version and confirm it's PHP 8.3 or higher.

    console
    $ php -v
    
  3. Install PHP-FPM and all required PHP extensions for Invoice Ninja.

    console
    $ sudo apt install php8.3-bcmath php8.3-gmp php8.3-fileinfo \
        php8.3-gd php8.3-mbstring php8.3-pdo php8.3-xml php8.3-cli \
        php8.3-curl php8.3-zip php8.3-gmp php8.3-mysql php8.3-fpm -y
    
  4. Enable Nginx to start at boot.

    console
    $ sudo systemctl enable nginx
    
  5. Start the Nginx system service.

    console
    $ sudo systemctl start nginx
    
  6. Check the Nginx service status and verify that it's running.

    console
    $ sudo systemctl status nginx
    

    Output:

    ● nginx.service - A high performance web server and a reverse proxy server
        Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled)
        Active: active (running) since Fri 2025-05-02 00:34:30 UTC; 1s ago
    ...

Create a MySQL Database for Invoice Ninja

Invoice Ninja requires a MySQL database to run correctly on your server. Use the following steps to create a new MySQL database for Invoice Ninja.

  1. Log in to MySQL as the root database user.

    console
    $ sudo mysql -u root
    
  2. Create a new invoiceninjadb database.

    sql
    mysql> CREATE DATABASE invoiceninjadb;
    
  3. Create a new invoiceninja-admin user with a strong password. Replace secure-password with your actual password.

    sql
    mysql> CREATE USER 'invoiceninja-admin'@'localhost' IDENTIFIED BY 'secure-password';
    
  4. Grant the invoiceninja-admin user full privileges to the invoiceninjadb database.

    sql
    mysql> GRANT ALL PRIVILEGES ON invoiceninjadb.* TO 'invoiceninja-admin'@'localhost';
    
  5. Flush the MySQL privileges table to apply the user permission changes.

    sql
    mysql> FLUSH PRIVILEGES;
    
  6. Exit the MySQL database console.

    sql
    mysql> EXIT;
    

Download Invoice Ninja

Use the following steps to download the latest Invoice Ninja release file and install it on your server.

  1. Create a new invoiceninja directory in /var/www/.

    console
    $ sudo mkdir -p /var/www/invoiceninja
    
  2. Switch to the invoiceninja directory.

    console
    $ cd /var/www/invoiceninja
    
  3. Visit the Invoice Ninja releases page and verify the latest version to download. For example, run the following command to download version 5.11.72 using Wget.

    console
    $ sudo wget https://github.com/invoiceninja/invoiceninja/releases/download/v5.11.72/invoiceninja.tar.gz
    
  4. Extract all files from the downloaded invoiceninja.tar.gz archive.

    console
    $ sudo tar -xvf invoiceninja.tar.gz
    
  5. Remove the archive to save your disk space.

    console
    $ sudo rm invoiceninja.tar.gz
    
  6. Copy the .env.example file to create a new .env file.

    console
    $ sudo cp .env.example .env
    
  7. Grant the www-data Nginx user and group full permissions to the invoiceninja directory.

    console
    $ sudo chown -R www-data:www-data /var/www/invoiceninja
    
  8. Open the system crontab as the www-data user.

    console
    $ sudo -u www-data crontab -e
    
  9. Add the following Laravel schedule command to run regular maintenance tasks for Invoice Ninja.

    ini
    * * * * * php8.3 /var/www/invoiceninja/artisan schedule:run >> /dev/null 2>&1
    

    Save and close the Crontab file.

  10. Test the system's Crontab to verify that the Invoice Ninja task is active.

    console
    $ sudo -u www-data crontab -l
    

    Output:

    # m h  dom mon dow   command
    * * * * * php8.3 /var/www/invoiceninja/artisan schedule:run >> /dev/null 2>&1

Configure Invoice Ninja

Invoice Ninja requires a virtual host configuration to run all files in the /var/www/invoiceninja directory. Use the following steps to create a new Nginx virtual host configuration to serve InvoiceNinja.

  1. Create a new invoiceninja.conf virtual host configuration in the /etc/nginx/sites-available directory.

    console
    $ sudo nano /etc/nginx/sites-available/invoiceninja.conf
    
  2. Add the following Nginx server block configurations to the invoiceninja.conf file. Replace invoiceninja.example.com with your domain.

    ini
    server {
        listen 80;
        listen [::]:80;
        server_name invoiceninja.example.com;
    
        root /var/www/invoiceninja/public;
        index index.php index.html index.htm;
    
        client_max_body_size 20M;
        charset utf-8;
    
        access_log /var/log/nginx/ininja.access.log;
        error_log /var/log/nginx/ininja.error.log;
    
        gzip on;
        gzip_types application/javascript application/x-javascript text/javascript text/plain application/xml application/json;
        gzip_proxied no-cache no-store private expired auth;
        gzip_min_length 1000;
    
        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }
    
        if (!-e $request_filename) {
            rewrite ^(.+)$ /index.php?q= last;
        }
    
        location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/run/php/php8.3-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;
        }
    
    }
    

    Save and close the invoiceninja.conf file.

    The above Nginx virtual host configuration serves Invoice Ninja files from the /var/www/invoiceninja/public directory using the invoiceninja.example.com domain. All PHP requests are forwarded to the installed PHP 8.3 FPM service to process and serve the Invoice Ninja dashboard.

  3. Remove the default Nginx virtual host configuration.

    console
    $ sudo rm /etc/nginx/sites-enabled/default
    
  4. To enable this virtual host, link the invoiceninja.conf file to the /etc/nginx/sites-enabled directory.

    console
    $ sudo ln -s /etc/nginx/sites-available/invoiceninja.conf /etc/nginx/sites-enabled/invoiceninja.conf
    
  5. Test the Nginx configuration for syntax errors.

    console
    $ sudo nginx -t
    

    Output:

    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
  6. Restart Nginx to apply the Invoice Ninja virtual host configurations.

    console
    $ sudo systemctl restart nginx
    

Secure Invoice Ninja with Trusted SSL Certificates

Use the following steps to generate trusted Let's Encrypt SSL certificates to secure all connections to Invoice Ninja.

  1. Install the Certbot Let's Encrypt plugin for Nginx.

    console
    $ sudo apt install python3-certbot-nginx
    
  2. Request a new TLS certificate using your virtual host domain. Replace invoiceninja.example.com with your active domain and admin@example.com with your email address.

    console
    $ sudo certbot --nginx -d invoiceninja.example.com -m admin@example.com --agree-tos
    
  3. Restart Nginx to apply the Invoice Ninja configuration changes.

    console
    $ sudo systemctl restart nginx
    

Set Up Invoice Ninja

  1. Access the /setup path using your invoiceninja.example.com domain in a web browser.

    https://invoiceninja.example.com/setup
  2. Verify that the Invoice Ninja configuration page displays correctly.

    Invoice Ninja Page

  3. Enter your domain in the URL field and keep the HTTPS Require option enabled.

  4. Navigate to Database Connection.

  5. Verify that MySQL is the selected driver.

    Setup the Invoice Ninja Database Connection

  6. Keep localhost as the MySQL host or specify your MySQL database server address.

  7. Keep 3306 as the MySQL port or set it depending on your server port.

  8. Enter the Invoice Ninja database, username, and password information you created earlier.

  9. Click Test connection to validate the MySQL connection information and verify that a success prompt displays.

  10. Enter your Invoice Ninja administrator details in the User Details form.

    Set Invoice Ninja User Details

  11. Check the Invoice Ninja terms of service and privacy policy options.

  12. Click Submit to apply the Invoice Ninja configuration.

Access and Use Invoice Ninja

Use the following steps to access and use Invoice Ninja on your server.

  1. Open the Invoice Ninja login page using your domain in a new web browser tab..

    https://invoiceninja.example.com/login
  2. In the respective fields, enter your administrator email address and password and click Login to access the Invoice Ninja dashboard.

    Login to Invoice Ninja

  3. In the open Welcome to Invoice Ninja prompt, enter your company name, such as example-company, and select the default currency to use in your invoices.

    Set Company Name

  4. Navigate to Settings to fill-in your additional company information.

  5. Click Invoices on the main navigation menu.

    New Invoice

  6. Click New Invoice to create a new invoice.

  7. Click New Client, enter the client's details, and click Save.

    Create a new Invoice

  8. In the respective fields, set the Invoice date, due date, invoice number, PO, and discount information.

  9. Click Add Item within the Products category to add new items to the invoice.

  10. Click New Product, specify the Item details, and click Save.

    Create a new product

  11. Specify the unit cost and quantity details.

  12. Enter additional information by navigating between the Public Notes, Terms and Footer options.

  13. Scroll and verify the Invoice information on the preview page.

  14. Download or print the Invoice.

    Download an Invoice

  15. Click Save to export and save the Invoice in your collection.

Conclusion

In this article, you have deployed Invoice Ninja on an Ubuntu 24.04 server using the official package and using Docker. You can create invoices, manage records, and create financial records within the Invoice Ninja dashboard. For more information about Invoice Ninja, visit its documentation page.

Comments

No comments yet.