Docs
Amazon Lightsail

Amazon Lightsail

This guide explains how to deploy Collections projects on AWS Lightsail, using Let's Encrypt certificates to help minimize costs.

Amazon Lightsail Installation Requirements

Create a Lightsail instance

Log in to Amazon Lightsail (opens in a new tab) and create an instance of the following environment

  • Linux/Unix + Nginx
  • 2 GM RAM
⚠️

Collections requires at least 2GB of RAM to build and deploy the management interface.

Attach a static IP address

The IP address attached to a Lightsail instance is dynamic and changes each time the instance is restarted. Refer to the official AWS documentation (opens in a new tab) to attach a static IP address. After attaching, also make sure that the welcome page is displayed by accessing the static IP address.

Routing your own domain

Once the static IP address is attached, refer to the official AWS documentation (opens in a new tab) to find the example.com or other domain name to route to your Amazon Lightsail instance.

Alternatively, if your domain is already hosted on Route53, create an A record and specify a static IP address.

SSL certificates are issued and integrated into the instance

Enhance the security of your website and applications with SSL/TLS. Refer to official AWS documentation (opens in a new tab) to issue a Let's Encrypt certificate and integrate it into your instance, Integrate it into your instance.

Install Node.js

Access Lightsail via console and install Node.js.

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
source ~/.nvm/nvm.sh
nvm install --lts

Configure Nginx

Edit the Nginx configuration file and set Collections to the root directory. Here the domain name is collections.dev.

server {
    root /home/bitnami/stack/nginx/html/collections;
    include "/opt/bitnami/nginx/conf/bitnami/*.conf";

    server_name collections.dev app.collectionsdemo.live;

    location / {
            proxy_pass http://localhost:4000;
    }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/collections.dev/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/collections.dev/privkey.pem;

    location /status {
        stub_status on;
        access_log off;
        allow 127.0.0.1;
        deny all;
    }
}

server {
    listen 80;
    listen [::]:80;

    return 301 https://$host$request_uri;
}

Install Collections

Now it is time to install the application. First, go to the Nginx root directory, then run Collections installation.

cd /home/bitnami/stack/nginx/html
git clone git@github.com:collectionscms/collections.git

Configuring .env files

Copy and edit the .env file to set environment variables.

cd /home/bitnami/stack/nginx/html/collections
cp .env.sample .env
vi .env

Resolving Dependencies

npm install

DB Migration

npm run seed:dev

Build the application

npm run build

Running Applications on PM2

PM2 can keep Node.js processes running at all times and reload them without downtime. Run the following command to install PM2 globally.

npm install pm2@latest -g

Then, start PM2.

pm2 start /home/bitnami/stack/nginx/html/collections/dist/build/main.js --name collections

Restart

Finally, restart the basic service to reflect the changes.

sudo /opt/bitnami/ctlscript.sh restart
Contact