In this tutorial, we will show you how to install Invoice Ninja on an Ubuntu 18.04 VPS.
Invoice Ninja is an open-source software application for invoicing and billing customers. It is built using PHP and JavaScript, on top of the Laravel framework. Some of the features include recurring invoices, creating tasks, proposals, and projects, invoice designs, more than 40 payment options, and partial payments. Looking to get some fully managed hosting for your InvoiceNinja account? We offer complete migration, installation, optimization, and customization – 100% free of charge! Check out our premium affordable VPS hosting packages and switch to a more secure, more efficient server with 24/7/265 amazing customer support today.
Installing Invoice Ninja won’t take long – let’s get started.
This guide was tested and written for Ubuntu 18.04 VPSes, but it should work on other Linux VPS systems as well. If you want to install Invoice Ninja on CentOS 7, follow this tutorial instead.
Table of Contents
Step 1: Update the system packages
Log in to your VPS via SSH as root or as a sudo user:
ssh userame@IP_Address -p Port_Number
Replace IP_Address and Port_Number with your server’s respective IP address and SSH port numbers.
Then run the following commands to ensure all installed packages are up to date:
sudo apt-get update sudo apt-get upgrade
Step 2: Install Nginx, MySQL and PHP 7
To install Nginx, MySQL, PHP 7, and all other necessary PHP modules on your Ubuntu server, run the following apt command:
sudo apt-get install nginx php-fpm mysql-server php-cli php-common php-curl php-gd php-mysql php-xml php-mbstring
When the MySQL installation is complete, secure your MariaDB installation using the mysql_secure_installation
script:
sudo mysql_secure_installation
Then, answer the security questions as follows:
Securing the MySQL server deployment. Connecting to MySQL using a blank password. VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD plugin? Press y|Y for Yes, any other key for No: n Please set the password for root here. New password: Re-enter new password: By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? (Press y|Y for Yes, any other key for No) : y Success. Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y Success. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y - Dropping test database... Success. - Removing privileges on test database... Success. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y Success. All done!
That should be it. Next is to create a database where Invoice Ninja will store its data.
Step 3: Create a MySQL database
Log in to the MariaDB console with the MariaDB root user using the password you have set up in the previous step:
mysql -u root -p
Create a MariaDB database and user for Invoice Ninja, and grant permissions to the user using the following command:
mysql> CREATE SCHEMA `ninja` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> GRANT ALL PRIVILEGES ON ninja.* TO 'ninja'@'localhost' IDENTIFIED BY 'strongpassword';
mysql> FLUSH PRIVILEGES;
mysql> \q
Make sure you replace ‘strongpassword‘ with an actual strong password.
Step 4: Download Invoice Ninja
You can either download the zip archive from the Invoice Ninja website download.invoiceninja.com
or check out the code from the GitHub Invoice Ninja repository. If you clone the GitHub repository you will need to use Composer to install the Invoice Ninja PHP dependencies while the archive file includes all required third party PHP packages. In this guide, we will install Invoice Ninja using the zip archive.
Run the following command to download the latest stable version of the Invoice Ninja zip archive in the /tmp
directory on your server:
wget https://download.invoiceninja.com/ -O /tmp/invoice-ninja.zip
Once the download is complete, extract the archive in the /var/www/html/
directory:
sudo unzip /tmp/invoice-ninja.zip -d /var/www/html/
Change the file ownership to the www-data
user with the following command:
sudo chown -R www-data: /var/www/html/ninja
Step 5: Configure Nginx to Serve Invoice Ninja
Open your favorite text editor and create a new Nginx server block for the Invoice Ninja application. Make sure to replace all instances of your_invoice_ninja_domain.com
with your unique registered domain name:
sudo nano /etc/nginx/sites-available/your_invoice_ninja_domain.com.conf
server { listen 80 default_server; server_name your_invoice_ninja_domain.com www.your_invoice_ninja_domain.com; root /var/www/html/ninja/public; index index.php; charset utf-8; location / { try_files $uri $uri/ /index.php?$query_string; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } access_log /var/log/nginx/your_invoice_ninja_domain.com.access.log; error_log /var/log/nginx/your_invoice_ninja_domain.com.error.log; sendfile off; location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.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; } location ~ /\.ht { deny all; } }
Save and exit the file. Now, activate the server block by creating a symbolic link with the following command:
sudo ln -s /etc/nginx/sites-available/your_invoice_ninja_domain.com.conf /etc/nginx/sites-enabled/your_invoice_ninja_domain.com.conf
Test the Nginx configuration to ensure that there are no syntax errors using the following commands:
sudo nginx -t
Restart the nginx service:
sudo service nginx restart
Step 6: Install Invoice Ninja
Open http://your_invoice_ninja_domain.com/
in your preferred web browser and you will be redirected to the Invoice Ninja setup page.
On this page you need to enter the following information to finish the setup:
Application Settings
- URL: your_ninja_domain.com
- HTTPS: check the box if you have SSL installed
- Debug: do not check the box
Database Connection
- Driver: MySQL
- Host: localhost
- Database: ninja
- Username: ninja
- Password: strongpassword
Email Settings
Enter your email settings. You can use either you VPS SMTP or any supported third-party SMTP provider.
User Details
Enter your first name, last name, email address, and password. This user is your Invoice Ninja administrator account.
Finally, select the I agree to the Terms of Service and Privacy Policy and click on the Submit button to finish the installation.
That’s it. You have successfully installed Invoice Ninja on Ubuntu 18.04. For more information about how to manage your Invoice Ninja installation, please refer to the official Invoice Ninja documentation.
Of course, you don’t have to install Invoice Ninja on Ubuntu 18.04 if you use one of our Managed Linux VPS Hosting services, in which case you can simply ask our expert system administrators to install Invoice Ninja on Ubuntu 18.04 for you using the LEMP stack or any other web hosting stack of your choice. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post on how to install Invoice Ninja on Ubuntu 18.04, or if you found it helpful, please share it with your friends on the social networks using the buttons below or simply leave a comment in the comments section. Thanks.