Skip to main content

Deploying Paybill on Amazon AMI

info

You should setup a PostgreSQL database manually to be used by the Paybill server.

You can effortlessly deploy Amazon Elastic Compute Cloud Service (EC2) by utilizing a CloudFormation template. This template will deploy all the services required to run Paybill on AWS AMI instances.

To deploy all the services at once, simply employ the following template:

curl -LO https://raw.githubusercontent.com/paybilldev/paybill/refs/heads/master/deploy/cloudformation/EC2-cloudfomration.yml

Follow the steps below to deploy Paybill on AWS AMI instances.

  1. Setup a PostgreSQL database and make sure that the database is accessible from the EC2 instance.

  2. Login to your AWS management console and go to the EC2 management page.

    ✅ EC2 Dashboard (default region)

    🌍 EC2 Dashboard by Region:

    You can manually change the region in the URL (replace us-east-1 with your region):

  3. Under the Images section, click on the AMIs button.

  4. Find the Paybill version you want to deploy. Now, from the AMI search page, select the search type as "Public Images" and input the version you'd want AMI Name : paybill_vX.X.X.ubuntu_bionic in the search bar.

search ami image
  1. Select Paybill's AMI and bootup an EC2 instance.
    Creating a new security group is recommended. For example, if the installation should receive traffic from the internet, the inbound rules of the security group should look like this:

    protocolportallowed_cidr
    tcp22your IP
    tcp800.0.0.0/0
    tcp4430.0.0.0/0
  2. Once the instance boots up, SSH into the instance by running ssh -i <path_to_pem_file> ubuntu@<public_ip_of_the_instance>.

  3. Switch to the app directory by running cd ~/app.
    Modify the contents of the .env file. ( Eg: vim .env )

    The default .env file looks like this:

    APP_KEY=
    PG_DB=
    PG_USER=
    PG_HOST=
    PG_PASS=
    PB_DB=
    PB_DB_HOST=
    PB_DB_USER=
    PB_DB_PASS=

    Read environment variables reference

    info

    If there are self signed HTTPS endpoints that Paybill needs to connect to, please make sure that NODE_EXTRA_CA_CERTS environment variable is set to the absolute path containing the certificates.

  4. PB_DB_HOST environment variable determines where you can access the Paybill client. It can either be the public ipv4 address of your instance or a custom domain that you want to use.

    Examples: PB_DB_HOST=http://12.34.56.78 or PB_DB_HOST=https://yourdomain.com or PB_DB_HOST=https://paybill.yourdomain.com

    info

    We use a lets encrypt plugin on top of nginx to create TLS certificates on the fly.

    info

    Please make sure that PB_DB_HOST starts with either http:// or https://

  5. Once you've configured the .env file, run ./setup_app. This script will install all the dependencies of Paybill and then will start the required services.

  6. If you've set a custom domain for PB_HOST, add a A record entry in your DNS settings to point to the IP address of the EC2 instance.

  7. You're all done, Paybill client would now be served at the value you've set in PB_HOST.

Deploying Paybill Database

Paybill AMI comes inbuilt with Postgres. If you intend to use this feature, you'd only have to setup the environment variables in ~/app/.env file and run ./setup_app script.

You can learn more about this feature here.

Upgrading to the Latest LTS Version

New LTS versions are released every 3-5 months with an end-of-life of atleast 18 months. To check the latest LTS version, visit the Paybill Docker Hub page. The LTS tags follow a naming convention with the prefix LTS- followed by the version number, for example paybilldev/paybill:ee-lts-latest.

Note: If this is a new installation of the application, you may start directly with the latest version. This guide is not required for new installations.

Prerequisites for Upgrading to the Latest LTS Version:

  • It is crucial to perform a comprehensive backup of your database before starting the upgrade process to prevent data loss.

If you have any questions feel free to join our Discord Community or send us an email at info@paybill.dev.