Invoice Ninja is a free, open-source invoicing, billing, and payment management platform built for freelancers and small businesses. It supports recurring invoices, expense tracking, time tracking, quotes, and integrates with popular payment gateways like Stripe, PayPal, and many others. Version 5 is a complete rewrite using Laravel and React, offering a modern UI and improved performance over earlier releases.
This guide covers a full production installation of Invoice Ninja 5.13.2 on Ubuntu 24.04 with Apache, MariaDB, and PHP 8.3.
Prerequisites
Before you begin, make sure you have the following in place:
- Ubuntu 24.04 server with root or sudo access – see Install and Configure SSH Server on Ubuntu
- At least 2GB RAM (4GB recommended for production)
- A registered domain name pointed to your server IP
- Ports 80 and 443 open in your firewall
Step 1 – Update System and Install Dependencies
Start by updating the package index and upgrading installed packages:
sudo apt update && sudo apt upgrade -y
Install basic dependencies that Invoice Ninja requires:
sudo apt install -y curl wget git unzip software-properties-common
Step 2 – Install Apache, MariaDB, and PHP 8.3 (LAMP Stack)
Ubuntu 24.04 ships with PHP 8.3.6 in the default repositories. Install Apache, MariaDB, and all the PHP extensions Invoice Ninja needs in one command:
sudo apt install -y apache2 mariadb-server \
php php-{fpm,soap,bcmath,common,imagick,mysql,gmp,curl,intl,mbstring,gd,xml,cli,zip,bz2} \
libapache2-mod-php
Verify the installed PHP version:
php -v
Expected output:
PHP 8.3.6 (cli) (built: ...)
Copyright (c) The PHP Group
Zend Engine v4.3.6, Copyright (c) Zend Technologies
with Zend OPcache v8.3.6, Copyright (c), by Zend Technologies
Enable and start both Apache and MariaDB:
sudo systemctl enable --now apache2 mariadb
Tune PHP for Invoice Ninja
Invoice Ninja needs higher memory and upload limits than the PHP defaults. Edit the Apache PHP configuration:
sudo sed -i 's/memory_limit = .*/memory_limit = 512M/' /etc/php/8.3/apache2/php.ini
sudo sed -i 's/upload_max_filesize = .*/upload_max_filesize = 100M/' /etc/php/8.3/apache2/php.ini
sudo sed -i 's/post_max_size = .*/post_max_size = 100M/' /etc/php/8.3/apache2/php.ini
Confirm the changes:
grep -E "memory_limit|upload_max_filesize|post_max_size" /etc/php/8.3/apache2/php.ini | head -3
Step 3 – Secure MariaDB
Run the MariaDB security script to set a root password, remove anonymous users, disable remote root login, and drop the test database:
sudo mysql_secure_installation
Answer the prompts as follows:
- Switch to unix_socket authentication: N
- Set root password: Y (enter a strong password)
- Remove anonymous users: Y
- Disallow root login remotely: Y
- Remove test database: Y
- Reload privilege tables: Y
Step 4 – Create Database and User
Log into MariaDB and create a dedicated database and user for Invoice Ninja:
sudo mysql -u root -p
Run these SQL statements (replace StrongPassword123! with your own password):
CREATE DATABASE invoiceninja CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'ninjauser'@'localhost' IDENTIFIED BY 'StrongPassword123!';
GRANT ALL PRIVILEGES ON invoiceninja.* TO 'ninjauser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 5 – Download and Extract Invoice Ninja 5.13.2
The latest Invoice Ninja release is distributed as a .tar archive from the GitHub repository. Fetch the latest version number automatically and download it:
VER=$(curl -s https://api.github.com/repos/invoiceninja/invoiceninja/releases/latest \
| grep tag_name | cut -d '"' -f 4 | sed 's/v//')
echo "Downloading Invoice Ninja v${VER}..."
curl -sL -o /tmp/invoiceninja.tar \
"https://github.com/invoiceninja/invoiceninja/releases/download/v${VER}/invoiceninja.tar"
Extract the archive to /var/www/:
sudo tar xf /tmp/invoiceninja.tar -C /var/www/
The extracted directory name may include the version number. Rename it to a clean path:
sudo mv /var/www/invoiceninja* /var/www/invoiceninja
Verify the files are in place:
ls /var/www/invoiceninja/
You should see directories like app, bootstrap, config, public, vendor, and the .env.example file.
Clean up the downloaded archive:
rm -f /tmp/invoiceninja.tar
Step 6 – Configure the .env File
Invoice Ninja uses a .env file for all configuration. Copy the example file and edit it:
cd /var/www/invoiceninja
sudo cp .env.example .env
sudo nano .env
Update the following values in the file. Replace the domain, database password, and mail settings with your actual values:
APP_URL=https://invoice.example.com
APP_DEBUG=false
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=invoiceninja
DB_USERNAME=ninjauser
DB_PASSWORD=StrongPassword123!
MAIL_MAILER=smtp
MAIL_HOST=smtp.example.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=your-mail-password
MAIL_ENCRYPTION=tls
[email protected]
MAIL_FROM_NAME="Invoice Ninja"
Save and close the file when done.
Step 7 – Set File Permissions
Apache runs as the www-data user. Set ownership and permissions so Invoice Ninja can read and write the files it needs:
sudo chown -R www-data:www-data /var/www/invoiceninja
sudo chmod -R 755 /var/www/invoiceninja
sudo chmod -R 775 /var/www/invoiceninja/storage
sudo chmod -R 775 /var/www/invoiceninja/bootstrap/cache
Step 8 – Configure Apache Virtual Host
Create an Apache virtual host configuration for Invoice Ninja. Replace invoice.example.com with your actual domain:
sudo tee /etc/apache2/sites-available/invoiceninja.conf > /dev/null <<'VHOST'
<VirtualHost *:80>
ServerName invoice.example.com
DocumentRoot /var/www/invoiceninja/public
<Directory /var/www/invoiceninja/public>
AllowOverride All
Require all granted
Options -Indexes +FollowSymLinks
</Directory>
ErrorLog ${APACHE_LOG_DIR}/invoiceninja-error.log
CustomLog ${APACHE_LOG_DIR}/invoiceninja-access.log combined
</VirtualHost>
VHOST
Enable the site, the required Apache modules, and disable the default site:
sudo a2ensite invoiceninja.conf
sudo a2dissite 000-default.conf
sudo a2enmod rewrite
sudo apache2ctl configtest
If the config test returns Syntax OK, restart Apache:
sudo systemctl restart apache2
Step 9 – Run Artisan Commands
Generate the application key, run database migrations, and optimize the application cache:
cd /var/www/invoiceninja
sudo -u www-data php artisan key:generate --force
sudo -u www-data php artisan migrate --seed --force
sudo -u www-data php artisan optimize
The migrate --seed command creates all database tables and populates them with the required default data. This may take a minute depending on your server.
Step 10 – Configure Cron Job for Invoice Ninja
Invoice Ninja uses Laravel’s task scheduler for recurring invoices, sending reminders, and other background tasks. Add a cron job for the www-data user:
sudo crontab -u www-data -e
Add this line at the bottom of the file:
* * * * * cd /var/www/invoiceninja && php artisan schedule:run >> /dev/null 2>&1
This runs the scheduler every minute. Laravel internally determines which tasks are due.
Step 11 – Configure UFW Firewall
If UFW is active on your server, allow HTTP and HTTPS traffic:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload
Verify the rules are in place:
sudo ufw status
You should see ports 80 and 443 listed as ALLOW.
Step 12 – Access the Invoice Ninja Web UI
Open your browser and navigate to your domain:
http://invoice.example.com
You will see the Invoice Ninja setup wizard. It walks you through creating the first admin account, verifying your database connection, and configuring basic settings like company name and currency.
After completing the wizard, log in with the admin credentials you just created. The dashboard gives you access to clients, invoices, payments, expenses, and reports.
Enable HTTPS with Let’s Encrypt (Recommended)
For production use, you should secure Invoice Ninja with a TLS certificate. Install Certbot and obtain a free Let’s Encrypt certificate:
sudo apt install -y certbot python3-certbot-apache
sudo certbot --apache -d invoice.example.com
Certbot will automatically configure Apache to redirect HTTP to HTTPS. Verify auto-renewal is set up:
sudo certbot renew --dry-run
After enabling HTTPS, make sure the APP_URL in your .env file starts with https://. Then clear the config cache:
cd /var/www/invoiceninja
sudo -u www-data php artisan optimize:clear
sudo -u www-data php artisan optimize
Production Tips
A few things to keep in mind for a production Invoice Ninja deployment:
- Backups – Set up automated database backups with
mysqldumpormariadb-dumpand back up the/var/www/invoiceninja/storagedirectory where uploaded files and logos are stored. - Updates – Check the Invoice Ninja GitHub releases page regularly. To update, download the new
.tarfile, extract it over the existing installation, and runphp artisan migrate --forcefollowed byphp artisan optimize. - Email delivery – For reliable invoice email delivery, use a transactional email service like Postmark, Mailgun, or Amazon SES rather than your server’s local mail.
- PDF generation – Invoice Ninja uses Snappdf for PDF generation. If PDF generation fails, make sure the
storagedirectory has correct write permissions and that Chromium dependencies are installed. - Monitoring – Check the application logs at
/var/www/invoiceninja/storage/logs/laravel.logwhen troubleshooting issues.
Conclusion
Invoice Ninja 5 is now installed and running on your Ubuntu 24.04 server with Apache, MariaDB, and PHP 8.3. You have a working LAMP-based invoicing platform with the scheduler configured for recurring tasks, and HTTPS ready for production traffic. From here, configure your payment gateways, customize your invoice templates, and start billing.
Related Guides
- Install and Configure SSH Server on Ubuntu
- How to Install LAMP Stack on Ubuntu
- Install Let’s Encrypt SSL on Ubuntu with Certbot
- How to Install MariaDB on Ubuntu



























































