Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Important: PHP 7.2 is for legacy Invoice Ninja 4.x deployments, not a new production installation. Invoice Ninja 4.5.50 documentation targets PHP 7.1/7.2, while current Invoice Ninja 5 requires PHP 8.1 or newer (the detailed current guide specifies PHP 8.2). See the current requirements before proceeding. Version 5 is a separate installation and migration from v4, not an in-place PHP upgrade.

Choose the correct installation path first

This procedure is appropriate when you must maintain or reproduce an existing Invoice Ninja 4 environment on an older Ubuntu server. Historical tutorials generally use Ubuntu 16.04 or 18.04. Ubuntu 18.04 can be suitable for an isolated legacy system, but neither it nor PHP 7.2 should be used for a new Internet-facing server in 2026.

Requirement Legacy v4 procedure Current v5 guidance
PHP PHP 7.1 or 7.2 for the archived v4.5.50 documentation PHP 8.1 minimum; the detailed guide specifies PHP 8.2
Ubuntu Typically Ubuntu 16.04/18.04 Supported Ubuntu release; current examples use Ubuntu 22.04
Upgrade model Pin the v4 release and its dependencies Install separately and migrate; v5 is not an in-place v4 upgrade

Use the archived v4 documentation for release-specific behavior and the current self-host guide for a new deployment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Before you begin

  • A server with sudo access and a DNS name such as invoices.example.com.
  • SSH access and firewall rules allowing SSH, HTTP (80), and HTTPS (443).
  • At least 1 GB RAM, 1 vCPU, and 20 GB storage as practical baseline guidance; 2 GB RAM or more is safer for PDFs, attachments, queues, and multiple users. These figures come from the current Invoice Ninja requirements, not a guaranteed v4 minimum.
  • A tested backup if this is an existing installation.

Create a dedicated DNS A/AAAA record before testing the virtual host. Do not expose an obsolete Ubuntu/PHP 7.2 system without compensating isolation, firewalling, and HTTPS controls.

#1 Best Overall
Express Invoice Billing and Invoicing Software Free [PC Download]
  • Easily create invoices, orders, and quotes and customize them including logo, heading text, notes and more
  • Access the web interface on mobile devices secure and safe
  • Email, print and fax direct from the application
  • Loaded with invoice templates and presets
  • Manage all your customer accounts and information

Install Apache2, MariaDB, and versioned PHP packages

Do not use the unversioned php package in a legacy guide: on some releases it installs a newer PHP version that is incompatible with v4. Package availability depends on the Ubuntu release and configured repositories; older systems may require a third-party repository, which must be evaluated for maintenance and trust.

sudo apt update
sudo apt install -y apache2 mariadb-server unzip curl git 
  php7.2 php7.2-cli libapache2-mod-php7.2 
  php7.2-common php7.2-mysql php7.2-mbstring 
  php7.2-xml php7.2-gd php7.2-curl php7.2-zip 
  php7.2-bcmath php7.2-intl php7.2-soap

These extensions cover the modules commonly required by the archived v4 installation material. Confirm that your selected v4 release does not require an additional module.

php -v
php -m
apache2ctl -M | grep php
  • php -v should report PHP 7.2.x.
  • php -m should list the database, XML, GD, cURL, ZIP, BCMath, Intl, SOAP, and multibyte extensions.
  • The Apache module check should show the PHP 7.2 module.

CLI PHP and Apache PHP can differ when several versions are installed. Resolve that mismatch before running the installer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Secure MariaDB and create a least-privilege database

sudo systemctl enable --now mariadb
sudo systemctl status mariadb
sudo mysql_secure_installation

The hardening prompts vary by MariaDB version. Review each one and remove anonymous users, disallow remote root login, remove the test database, and reload privilege tables rather than blindly assuming a fixed prompt sequence.

sudo mariadb
CREATE DATABASE ninja CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

CREATE USER 'ninja'@'localhost'
  IDENTIFIED BY 'REPLACE_WITH_A_LONG_RANDOM_PASSWORD';

GRANT ALL PRIVILEGES ON ninja.* TO 'ninja'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Use a generated password stored in a password manager; never use the example word ninja as a production password. Keep the account at localhost unless remote database access is intentional, and never grant global privileges such as GRANT ALL ON *.*.

Test the credentials before continuing:

mariadb -u ninja -p -h 127.0.0.1 ninja

Obtain a pinned Invoice Ninja 4 release

Do not download a moving “latest” artifact: current downloads and repository instructions target v5. Pin the exact v4 release you operate, such as v4.5.50, and verify its asset on the official release list. The archived documentation also references download.invoiceninja.com, but a moving endpoint must not be assumed to remain a v4 archive.

Rank #2
Sale
MyInvoices & Estimates Deluxe
  • #1 Best Selling Invoice Software
  • Create Custom Invoices, Estimates & Statements
  • Receive Payments & Track Invoices in One Place
  • Generate Reports on Sales, Invoices, Inventory & More
  • PLUS! Data Backup, Label Creation & Credit Card Processing

Preferred archive method

Download the v4.5.50 archive asset shown for that release, verify the downloaded file, and extract it into /var/www. Rename the extracted directory to /var/www/invoiceninja. A prebuilt archive is usually simpler because it includes third-party libraries.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Git and Composer method

Use this only when you have confirmed that the tag and Composer version are compatible with PHP 7.2:

cd /var/www
sudo git clone --branch 'v4.5.50' 
  https://github.com/invoiceninja/invoiceninja.git invoiceninja
cd /var/www/invoiceninja
sudo -u www-data composer install --no-dev --optimize-autoloader

Current repository examples refer to v5 and modern dependencies, so do not copy them unmodified into a PHP 7.2 deployment. A Composer failure commonly means the tag, lockfile, Composer version, or PHP runtime does not match.

Set ownership and writable directories

sudo chown -R www-data:www-data /var/www/invoiceninja
sudo find /var/www/invoiceninja -type d -exec chmod 755 {} ;
sudo find /var/www/invoiceninja -type f -exec chmod 644 {} ;
sudo chmod -R u+rwX /var/www/invoiceninja/storage
sudo chmod -R u+rwX /var/www/invoiceninja/bootstrap/cache

The archived v4 guidance also identifies bootstrap, public/logo, and related application directories as needing appropriate write access. Do not use chmod -R 777 as a production fix; world-writable code and storage expose the application unnecessarily.

Configure Apache2 and point it at public

Serving /var/www/invoiceninja/public prevents direct web access to the project’s environment and source files. Subdirectory URLs such as https://example.com/ninja are not supported by default in current guidance; use a dedicated domain or subdomain.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo a2enmod rewrite
sudo tee /etc/apache2/sites-available/invoiceninja.conf > /dev/null <<'EOF'
<VirtualHost *:80>
    ServerName invoices.example.com
    DocumentRoot /var/www/invoiceninja/public

    <Directory /var/www/invoiceninja/public>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/invoiceninja-error.log
    CustomLog ${APACHE_LOG_DIR}/invoiceninja-access.log combined
</VirtualHost>
EOF
sudo a2ensite invoiceninja.conf
sudo a2dissite 000-default.conf
sudo apache2ctl configtest
sudo systemctl reload apache2

Replace the example hostname with your real DNS name. The expected configuration-test result is Syntax OK. AllowOverride All lets Invoice Ninja’s .htaccess rules work. If Apache serves the wrong site, inspect enabled sites and the default virtual host.

Configure the environment and run the web installer

For releases that include the example file:

cd /var/www/invoiceninja
sudo -u www-data cp .env.example .env

Set the values appropriate to your release:

APP_URL=https://invoices.example.com
DB_DATABASE=ninja
DB_USERNAME=ninja
DB_PASSWORD=REPLACE_WITH_THE_DATABASE_PASSWORD
DB_HOST=127.0.0.1

Some v4 archives collect database and mail settings in the browser instead. Never publish or commit .env. Preserve the application key after installation: the current repository documentation warns that it encrypts data, and losing it can make the application unusable.

Open:

https://invoices.example.com/setup

Enter the database host, database name, user, and password; set the HTTPS application URL; create the administrator; and configure SMTP. If the setup page returns 404 or a server error, inspect the logs:

sudo tail -f /var/log/apache2/invoiceninja-error.log
sudo tail -f /var/log/apache2/error.log
sudo tail -f /var/www/invoiceninja/storage/logs/laravel-error.log

Enable HTTPS with Certbot

HTTPS should be mandatory for an invoicing system. Before requesting a certificate, ensure DNS resolves to this server, port 80 is reachable, and the HTTP virtual host works.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo apt install -y certbot python3-certbot-apache
sudo certbot --apache -d invoices.example.com

Package names and Certbot behavior vary by Ubuntu release or proxy arrangement. Test renewal with the command appropriate to your Certbot installation, and confirm that HTTP redirects to HTTPS without a loop.

Configure SMTP and scheduled work

SMTP delivery

Invoice reminders, password resets, notifications, and invoice mail depend on reliable SMTP. Prefer a transactional provider, configure its credentials in Invoice Ninja, send a test message, and verify SPF, DKIM, and DMARC for the sending domain. A local Postfix installation is not automatically reliable; historical guidance warns that major providers may reject mail without additional reputation and authentication work.

Cron and queues

Recurring invoices, reminders, and maintenance require a scheduler. Current Laravel documentation uses:

Rank #4
Express Accounts Accounting Software Free [PC Download]
  • Manage your payments and deposit transactions
  • Check balances and generate reports to monitor your business finances
  • Email and fax reports to your accountant
  • Create and track quotes, invoices and more
  • Connect to the app with secure web access
* * * * * cd /var/www/invoiceninja && php artisan schedule:run >> /dev/null 2>&1

Legacy v4 releases may expose different artisan commands. Check the selected v4 documentation and install the version-specific command under the application user:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo crontab -u www-data -e

Run the command manually as www-data once, then verify a recurring invoice or test notification rather than assuming cron is working.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Back up the database and application data

A complete backup includes both the MariaDB database and application data. Preserve .env, storage/, uploaded logos and documents, and any customizations. Copying only the code directory is insufficient.

sudo mkdir -p /var/backups
sudo mariadb-dump --single-transaction ninja 
  | gzip > /var/backups/invoiceninja-$(date +%F).sql.gz

Store backups off the server and perform a restore test. Keep the application key with the protected configuration backup.

Troubleshooting common failures

index.php appears in URLs

Enable rewrite support, confirm AllowOverride All, verify that the document root is /public, then reload Apache:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo a2enmod rewrite
sudo apache2ctl configtest
sudo systemctl reload apache2

Apache downloads PHP files

The PHP Apache module may be missing, disabled, or different from the CLI version:

Best Value
Express Invoice Software for Managing and Tracking Quotes, Invoices and Payments [Download]
  • Create invoices, quotes and orders quickly and professionally
  • Automate recurring invoices and statements to save time
  • Easily add multiple users and multiple businesses, enable remote access to view your data anwhere
  • Print, email or fax invoices directly to clients for faster payment
  • Use reports to track payments, overdue accounts, performance and more
apache2ctl -M | grep php
php -v
sudo systemctl restart apache2

Permission denied in storage

sudo chown -R www-data:www-data /var/www/invoiceninja/storage
sudo chmod -R u+rwX /var/www/invoiceninja/storage

Do not leave the directory at 777.

Database authentication fails

Check the database name, username, password, host (localhost versus 127.0.0.1), allowed host, and privileges. Test with the MariaDB client command shown earlier.

Composer or “Class not found” errors

Dependencies may be missing, partially copied, or incompatible with the Composer/PHP version. Ensure CLI and Apache use the same PHP major/minor version and regenerate dependencies only for the pinned v4 tag.

“Whoops, looks like something went wrong”

Read the Laravel and Apache logs. Never leave APP_DEBUG=true enabled on a public server; if enabled temporarily, disable it immediately after diagnosis.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

PDFs, logos, or email attachments fail

Verify GD and other required extensions, the HTTPS application URL, hostname resolution, and the legacy PDF dependency. Test invoice creation, PDF download, logo rendering, SMTP delivery, and attachments before declaring the deployment complete.

When to install Invoice Ninja 5 instead

For a new installation, use a supported Ubuntu release and the current Invoice Ninja 5 instructions, which require PHP 8.1 or newer and, in the detailed guide, PHP 8.2 plus additional extensions. Follow the official self-host installation guide or a supported deployment method. Existing v4 operators should back up first and follow the documented migration and troubleshooting guidance; replacing PHP or overwriting v4 files is not an upgrade path.

Quick Recap

Bestseller No. 1
Express Invoice Billing and Invoicing Software Free [PC Download]
Express Invoice Billing and Invoicing Software Free [PC Download]
Access the web interface on mobile devices secure and safe; Email, print and fax direct from the application
SaleBestseller No. 2
MyInvoices & Estimates Deluxe
MyInvoices & Estimates Deluxe
#1 Best Selling Invoice Software; Create Custom Invoices, Estimates & Statements; Receive Payments & Track Invoices in One Place
$29.79
Bestseller No. 3
Bestseller No. 4
Express Accounts Accounting Software Free [PC Download]
Express Accounts Accounting Software Free [PC Download]
Manage your payments and deposit transactions; Check balances and generate reports to monitor your business finances
Bestseller No. 5
Express Invoice Software for Managing and Tracking Quotes, Invoices and Payments [Download]
Express Invoice Software for Managing and Tracking Quotes, Invoices and Payments [Download]
Create invoices, quotes and orders quickly and professionally; Automate recurring invoices and statements to save time
$69.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.