How to host Invoice Ninja on AWS Lightsail VM Instance - ServerAvatar

Published : Aug 17, 2023

Share This Post

cloud-platform

AWS Lightsail

AWS Lightsail is a simplified and cost-effective way to launch and manage virtual private servers (VPS) in the cloud. It provides a user-friendly interface for deploying and scaling VPS instances with pre-configured options for operating systems, applications, and storage. Additionally, it offers a predictable pricing model that includes a flat monthly fee based on the instance size and data transfer limits.

Get started with AWS Lightsail
application

Invoice Ninja

Invoice Ninja is an open-source application that simplifies invoicing and billing for entrepreneurs, freelancers, and small-to-medium businesses. With its intuitive interface and robust functionality, Invoice Ninja enables users to create and manage professional invoices effortlessly.

More info

Create VM Instance in AWS Lightsail

To create a server in AWS Lightsail, First log in to the AWS Lightsail console. Once you are there, Follow the steps given below.

Step 1: Go to Instance Creation Form

To access the instance creation form, Go to AWS Lightsail dashboard and click on the orange button with Create Instance text. See the following image for reference.

Create VM Instance in AWS Lightsail - Step 1

Step 2: Select the Location of your Instance

First of all, You have to select the location for your instance. It is always better to select a location closest to your major traffic source. It will decrease the latency for majority of your website visitors.

Create VM Instance in AWS Lightsail - Step 2

If you want to change the location of your server, You can simply update the current region in your AWS account.

Step 3: Select the OS for your Instance

After selecting the location, Select the operating system for your instance. In this case, First click on OS Only and then select Ubuntu 20.04 as an operating system just like the following image.

Create VM Instance in AWS Lightsail - Step 3

Step 4: Select SSH Key and Launch Script (Optional/Advanced)

This is an optional step. Here you can set the Launch script and the main SSH key for your server. If you don't understand launch script and SSH keys, Just ignore this step.

Create VM Instance in AWS Lightsail - Step 4

Step 5: Select the Plan

In this step, select the size of your VM instance. AWS Lightsail provides lots of different options when it comes to plans and pricing. The plan and pricing selection completely depends on the requirements of your site(s). So, select the plan based on the complexity and traffic of your sites.

Create VM Instance in AWS Lightsail - Step 5

Step 6: Verify and Create the Instance

Finally, Enter the name of your instance, number of instances you want to create and assign the tags accordingly for identification. Once done, click on the Create Instance button to start the instance creation process.

Create VM Instance in AWS Lightsail - Step 6

It might take a few minutes to deploy the instance. Once done, follow the below given step to update the firewall rules for the VM instance.

Step 7: Update Firewall Rules

ServerAvatar requires 43210 port open. In total, You need to keep the following ports open on the instance.

  • 22 (SSH): To access your server via SSH.
  • 80 (HTTP): To access your sites on HTTP.
  • 443 (HTTPS): To access your sites on HTTPS.
  • 43210 (ServerAvatar): To allow communication between ServerAvatar and your instance.

To update the firewall rules for a specific instance, Go to the AWS Lightsail dashboard and click on the name of the instance you want to update. Then go to the Networking section and add the missing firewall rules. After updating the firewall rules, the networking section of your Instance should look like the following image.

Create VM Instance in AWS Lightsail - Step 7

Initial Server Configuration

The Initial server configuration includes installation and configuration of various packages required to host your website. Usually, You have to write commands and modify configuration files. Luckily, With ServerAvatar, Your full server configuration and optimisation can be automated.

Here are the three ways to automatically configure your server with ServerAvatar.

Install and Setup Invoice Ninja on Cloud Using ServerAvatar

Step 1. Create Database

Access the Databases tab on the ServerAvatar server panel to create a MySQL Database.

image

Enter the credentials and click on the Create Database button.

image

Step 2. Change PHP-CLI Version

Deploying InvoiceNinja on the server requires PHP-CLI Version 8.1 or above at the server level. To configure the PHP-CLI version, follow the Snapshot.

image

Step 3. Create PHP Application

Access the Applications tab from the server panel to create a new PHP application.

image

Fill up the required information, including the Application Name, Domain Name, and Advanced Options for more PHP settings.

image

Proceeds to next by clicking on the Next Step.

Now select method and service provider Git and GitHub, respectively (follow according to Snapshot)

image

Enter the required information as given below:

Repository Type: Public
Clone HTTPS URL: https://github.com/invoiceninja/invoiceninja.git
Branch: v5-stable
Deployment script:

git checkout v5-stable;
cp .env.example .env;
composer i -o --no-dev
php artisan key:generate

image

Move further by clicking on the Next Step.

Create a System User or choose a system user from an existing One.

Then choose PHP version 8.1 or above; the custom webroot should be Public as in the given Snapshot.

Custom Webroot: Public

image

Then, click on Create Application button.

Step 4. Connect Database

go to the File Manager tab from the sidebar of the application. And access the public_html folder

image

Now check the Show Hidden Files box to access the .env file to change to the origional database credentials.

image

Change the following configuration to establish a connection with the database.

DB_DATABASE= Database_Name
DB_USERNAME= Database_Username
DB_PASSWORD=Database_Password

to access database credentials, go to the Database tab from the sidebar of the server panel and click the database that we created in the first step.

image

that's all, open your application URL in web browser to access Invoice Ninja setup page.

image

Tip: ServerAvatar provides a one-click solution for installing an SSL certificate on your domain. To install SSL, go to the application panel and click the SSL Certificate button to install automatic SSL in your application domain.