Step-by-Step Guide to Setting Up a Production Environment on AWS for Frappe/ERPNext

Learn how to set up a secure and scalable AWS production environment for Frappe/ERPNext with this step-by-step guide, covering instance setup, networking, and deployment.

 · 5 min read

Introduction

Setting up a production environment on AWS is essential for ensuring scalability, security, and high availability of applications. AWS provides a robust cloud infrastructure with various services to support deployment, monitoring, and maintenance. This guide walks through the step-by-step process of configuring an AWS production setup, from creating an account to installing Frappe/ERPNext and securing the environment.

Aws setup:

Step 1:

Sign up with an AWS account using your email ID and phone number

Registration link https://signin.aws.amazon.com/signup?request_type=register

based on the video below. 

https://www.youtube.com/watch?v=lIdh92JmWtg


Step 2. After registration login with root user.

  1. Use your email ID and AWS password to sign in

Step:3 creating instance

  1. On the home page, you can see the link called Lightsail or use the search bar to get the link
  2. Get into that
  3. After getting into the link go to the instance and click Create instance
  4. In this select the instance location
  5. Select your platform(Linux /windows)
  6. Select the OS (ubuntu)
  7. And add SSH key pair (pem file) (it is a time download so save it in the secure file )
  8. Choose the suitable plan you want
  9. Use 24$ plan that is enough for basic usage
  10. In identifying your instance we want to give the name of the instance (eg client name or project name)
  11. Instead of Ubuntu change the name
  12. Click Create Instance to complete the instance process

Step:5 Set the network

  1. Once get into that go to the network tab
  2. In that, you can see the IP address. This IP will change every login so we need to set the IP as a static IP 
  3. Click the Attach static IP to set (static IP)
  4. After that click on the add rule in this we will set the ports like HTTPS.
  5. Now the port update and static IP are successfully updated 
  6. Then test the IP in your local host.


Step 6: SSH connection

  1. In vs-code go to connect to the host
  2. Before that, we want to give access to pem file
  3. Open the terminal get into the pen file folder and give this command #sudo chmod 600 (pem name)
  4. Go to the vs-code and connect to the host
  5. Paste the IP address
  6. That will create ssh configuration for that IP 
  7.  Host Host 1
  8.    HostName XXXXXXX
  9.    IdentityFile (Path to pem file)
  10.    User ubuntu

Step 7: once done go to terminal in vs code 

Step 8: create a user and permit the user by the below command            

sudo adduser [frappe-user]

usermod -aG sudo [frappe-user]

su [frappe-user] 

cd /home/[frappe-user]

the server-side process is completed 

 Installation process

  1. Now we want to install the setup
  2. Based on the D-code or code with the Karani document to install the prerequisites and bench.
  3. Here I use D-code documents -https://github.com/D-codE-Hub/Frappe-ERPNext-Version-15--in-Ubuntu-22.04-LTS
  4. The video is also there to set- https://youtu.be/TReR0I0O1Xo 

Steps to follow : 

Frappe-ERPNext Version-15 in Ubuntu 22.04 LTS

A complete Guide to Install Frappe/ERPNext version 15 in Ubuntu 22.04 LTS

Refer to this for the default Python 3.11 setup

  1. D-codeE Video Tutorial

Pre-requisites

 Python 3.11+

  Node.js 18+

  Redis 5                   (caching and real-time updates)

  MariaDB 10.3.x / Postgres 9.5.x       (to run database-driven apps)

  yarn 1.12+                  (js dependency manager)

  pip 20+                   (py dependency manager)

  wkhtmltopdf (version 0.12.5 with patched qt) (for pdf generation)

  cron                     (bench's scheduled jobs: automated certificate renewal, scheduled backups)

  NGINX                    (proxying multitenant sites in production)



Steps to Install Python 3.11.xx



Note: If you use Ubuntu 23. xx or the latest, the default Python version is 3.11.xx. So you can skip the Python 3.11 installation steps

First, import the Python repository with the most up-to-date stable releases.

 sudo add-apt-repository ppa:deadsnakes/ppa -y

  sudo apt update

installs Python 3.11 by executing the following command in your terminal:

 sudo apt install python3.11

  python3.11 --version

To install all the extras in one go, run the following command.

 sudo apt install python3.11-full

Refer to this for the default Python 3.11 setup

  1. www.linuxcapable.com
  2. ubuntuhandbook.org



STEP 1 Install git

sudo apt-get install git

STEP 2 install python-dev

sudo apt-get install python3-dev

STEP 3 Install setup tools and pip (Python's Package Manager).

sudo apt-get install python3-setuptools python3-pip

STEP 4 Install virtualenv

sudo apt install python3.11-venv

STEP 5 Install MariaDB

sudo apt-get install software-properties-common

sudo apt install mariadb-server

sudo mysql_secure_installation

  To log into MariaDB to secure it, we'll need the current

  password for the root user. If you've just installed MariaDB, and

  haven't set the root password yet, you should just press enter here.

  Enter current password for root (enter for none): # PRESS ENTER

  OK, successfully used the password, moving on...

  Switch to unix_socket authentication [Y/n] Y

  Enabled successfully!

  Reloading privilege tables…

   ... Success!

  Change the root password? [Y/n] Y

  New password: 

  Re-enter new password: 

  Password updated successfully!

  Reloading privilege tables..

   ... Success!

  Remove anonymous users? [Y/n] Y

   ... Success!

   Disallow root login remotely? [Y/n] Y

   ... Success!

   Remove the test database and access it. [Y/n] Y

   - Dropping test database...

   ... Success!

   - Removing privileges on test database...

   ... Success!

   Reload privilege tables now? [Y/n] Y

   ... Success!

STEP 6 MySQL database development files

sudo apt-get install libmysqlclient-dev

STEP 7 Edit the MariaDB configuration ( Unicode character encoding )

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

add this to the 50-server.cnf file

[server]

user = mysql

pid-file = /run/mysqld/mysqld.pid

socket = /run/mysqld/mysqld.sock

basedir = /usr

datadir = /var/lib/mysql

tmpdir = /tmp

lc-messages-dir = /usr/share/mysql

bind-address = 127.0.0.1

query_cache_size = 16M

log_error = /var/log/mysql/error.log

[mysqld]

innodb-file-format=barracuda

innodb-file-per-table=1

innodb-large-prefix=1

character-set-client-handshake = FALSE

character-set-server = utf8mb4

collation-server = utf8mb4_unicode_ci      

 

[mysql]

default-character-set = utf8mb4

Now press (Ctrl-X) to exit

sudo service mysql restart

STEP 8 Install Redis

sudo apt-get install redis-server

STEP 9 Install Node.js 18. X Package

sudo apt install curl 

curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

source ~/.profile

nvm install 18

STEP 10 install Yarn

sudo apt-get install npm

sudo npm install -g yarn

STEP 11: install wkhtmltopdf

sudo apt-get install xvfb libfontconfig wkhtmltopdf

STEP 12: install frappe-bench

sudo -H pip3 install frappe-bench

bench --version

STEP 13: initilise the frappe bench & install frappe latest version

bench init frappe-bench --frappe-branch version-15 --python python3.11

cd frappe-bench/

Step 14: Production setup command

  sudo bench setup production [frappe-user] 

                       Site and app installation and setup

Domain setup:

  1. Login to the domain or buy a new domain
  2. Go to DNS records
  3. Mark the IP with point “A”
  4. Once done check with -https://www.nslookup.io/
  5. For checking whether the domain is created or not(It may take some time)
  6. After this go to vs-code connect with ssh and open the terminal.
  7. Switch into frappe user and permitted by this command - chmod o+x /home/frappe
  8.  Go to the frappe bench 
  9. Create a new site by this command - bench new-site site name
  10. Add site password 
  11. Install wanted apps by this command -bench get-app app name --branch v-15
  12. Install Basic apps like Erpnext, Hrms, India_compliance, Payments
  13. After that install the app on the site by this command -bench --site (site name) install-app (app name)
  14. Once done Use certbot to get a license for HTTPS service
  15. Install Certbot
  16. Run this command on the machine's command line to install Certbot.


sudo snap install --classic certbot

  1. Prepare the Certbot command
  2. Execute the following instructions on the machine command line to ensure that the certbot command can be run.


sudo ln -s /snap/bin/certbot /usr/bin/certbot

  1. Choose how you'd like to run Certbot
  2. Either get and install your certificates...
  3. Run this command to get a certificate and have Certbot edit your Nginx configuration automatically to serve it, turning on HTTPS access in a single step.

 sudo certbot --nginx

Site migration and bench restart

  1. Migrate the site with this command

  bench --site {site name} migrate. 

  1. Restart the bench

  bench restart


Conclusion

Setting up a production environment on AWS requires careful planning and execution. Following this guide can ensure a robust deployment with secure configurations, optimized performance, and automated processes. AWS offers flexibility and scalability, making it ideal for hosting applications like Frappe/ERPNext. As you move forward, consider implementing additional security measures, auto-scaling strategies, and continuous monitoring to maintain a stable and efficient production environment.

                 


No comments yet.

Add a comment
Ctrl+Enter to add comment