Invoice Ninja is a free, open-source, self-hosted application for invoicing and billing customers. It is written in PHP with a Laravel framework. Invoice Ninja is specially designed for freelancers & businesses for invoicing, accept payments, track expenses, create proposals, and time tasks. It allows you to create and send invoices to clients with your own domain name and brand. Invoice Ninja supports 40+ payment gateways including WePay, GoCardless, PayPal, Authorize.net, 2Checkout, and more.
In this post, we will show you how to install Invoice Ninja with Nginx on Debian 12.
Prerequisites
- A fresh Debian 12 server
- A valid domain name pointed to your virtual private server
- A root password configured on your server
Step 1 – Install LEMP Server
First, you will need to install Nginx, MariaDB, PHP, and other PHP extensions on your server. You can install all of them with the following command:
apt-get install nginx mariadb-server php php-zip php-bcmath php-fpm php-cli php-common php-curl php-gd php-mysql php-xml php-mbstring unzip -y
Once all the packages are installed, stop the Apache, start the Nginx and MariaDB service if not started.
systemctl stop apache2 systemctl start nginx systemctl start mariadb
Step 2 – Create a Database
Next, you will need to create a database and user for Invoice Ninja. First, log in to MariaDB with the following command:
mysql
Once connected, create a database and user with the following command:
CREATE DATABASE ninja; GRANT ALL PRIVILEGES ON ninja.* TO 'ninja'@'localhost' IDENTIFIED BY 'password';
Next, flush the privileges and exit from the MariaDB with the following command:
FLUSH PRIVILEGES; EXIT;
Step 3 – Download Invoice Ninja
Next, download the latest version of Invoice Ninja with the following command:
wget https://github.com/invoiceninja/invoiceninja/releases/download/v5.11.72/invoiceninja.tar.gz
Once the download is completed, extract the downloaded file to the Nginx root directory:
cd /var/www/html tar -xvzf invoiceninja.tar.gz
Next, copy the example environment file.
cp .env.example .env
Next, change the ownership of the invoiceninja directory to www-data:
chown -R www-data:www-data /var/www/html/
Set proper permissions.
chmod -R 775 *
Step 4 – Configure Nginx for Invoice Ninja
Next, you will need to create an Nginx virtual host configuration file for Invoice Ninja.
You can create it with the following command:
nano /etc/nginx/conf.d/ninja.conf
Add the following lines:
server { listen 80; server_name ninja.example.com; root /var/www/html/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.2-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 file, then verify the Nginx for any syntax errors with the following command:
nginx -t
Finally, restart the Nginx service to apply the changes:
systemctl restart nginx
Step 5 – Access Invoice Ninja
Now, open your web browser and access the Invoice Ninja web interface using the URL http://ninja.example.com. You will be redirected to the following page:
Provide your Invoice Ninja URL, database details, and administrative user information, and click on the Next button. You will be redirected to the Invoice Ninja login page:
Provide your admin username and password and click on the Login button. You should see the Invoice Ninja dashboard on the following page:
Conclusion
Congratulations! You have successfully installed and configured Invoice Ninja on Debian 12. You can now implement Invoice Ninja in your organization and start invoicing and billing customers with your VPS from Atlantic.Net.