[AMAZON EC2] Installation Step by Step Tutorial

Greetings, I have recently installed the frappe framework and currently use ERPNext. There were some things I had trouble with so I would like to share a step by step tutorial I made for setting up ERPNext with an Amazon EC2 Instance:

Please let me know if there are any mistakes
The tutorial is not the safest approach


Updated: 05/09/2106

Cloud Service:     Amazon AWS
                Instance Type: t2.micro
                Instance OS: Ubuntu 14.04
Prerequisites:     Installed virtual server in a Linux enviornment, preferrable Ubuntu
                visit http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html
                
Part 1: Installing the cloud instance
-this is shortly go through how to install the cloud instnace

    1) Log into Amazon AWS (console.aws.amazon.com)
    2) Create an account if you have not already
    3) Click EC2, this is the service we will be using
    4) Under the Create Instance section click the Launch Instance button
    5) Select the Ubuntu Server 14.04 LTS (HVM), SSD Volume Type or similar
    6) Click Review and Launch
        *we are using the t2.micro which is default
        *customize the instance. the operating system is the important characteristic
    7) Click Launch after reviewing the instnace. Make sure it is as requested
    8) A popup should come up titled Select an existing key pair or create a new key pair
        *choose an existing key pair. for this example, we will assume you do not have one. follow the following:
            1) Choose Create a new key pair from the first drop down menu
            2) Name the Key pair name shaman_key
            3) IMPORTANT: Click Download Key Pair
                * without it we cannot login
            4) Click Launch Instances
    5) Click View Instances after reviewing the Launch Status page
    6) You should now be on the Instances tab on the EC2 Dashboard. Notice the table and specifically the Status Checks column
    7) Wait until there is a green check in the Status Check column that indicated the instance is ready
    * You have now created the virtual server for your site instance

Part 2: SSH Information
-this will go over how to use SSH with your new virtual server
Prerequisites: Completed Part 1, Linux enviornment. You can use puTTY for windows but the guide will use Ubuntu

    1) Open up terminal (shortcut: ctrl + alt + t)
    2) Navigate to where you downloaded the ssh key (enter ls to see current directory and cd [file] to access a file)
    3) Open up the Amazon AWS EC2 Dashboard and make sure you are on the Instances tab
        -we will now get the connection string. for experienced users, you can skip this
        1) Click on the virtual instance you would like to use your site on
        2) On the top bar, there should be a button called Connect. Click Connect
        3) In the Example section there is a bold string, it should look like this:
            ssh -i "shaman_key.pem" ubuntu@ec2-52-24-43-53.us-west-2.compute.amazonaws.com
        4) Copy this string and go back to the terminal
    4) Paste the string (Paste in terminal: Ctrl + Shift + Z)
    5) Press enter to connect
        note: there may be an error that will say: WARNING UNPROTECTED PRIVATE KEY FILE, follow these steps to 'protect' it
        1) Type in the collowing command to change the permissions of our key file (YOUR_KEY.pem)
            chmod 400 YOUR_KEY.pem
            *note that the 400 is a strict case, a higher number will be more lenient
    6) We have now connected to our virtual instance using ssh
    
Part 3: Create a User and use SFTP
-this will create a user for proper bench installation and make sure we can sftp into it for easier editing
Prerequisites: Part 1, 2 completed, SFTP client like FileZilla

    1) Connect to instance via SSH
    2) You might be the user ubuntu, we will now create a new user. go to root user by typing in the following command:
        sudo su -
    3) Set root password by typing in the following command (makes instance less secure)
        passwd
    4) Type in the following command where [name] is your name
        adduser [name]
    5) The terminal will ask for a series of questions for log information.
    6) Add the user into the sudoer group by entering the following command
        sudo adduser [name] sudo
    7) Set the password to the new user by entering in the following command (makes instance less secure)
        sudo passwd [name]
    8) Allow SSH Password Authentication by following these steps:
        1) Go to the root directoy of the OS (you can do this by entering the command "cd ..")
        2) Type in the following command to navigate to the correct directory:
            cd etc/ssh
        3) Edit the sshd_config file through the following steps
            1) enter the following command
                vi sshd_config
            2) type the following to go into the editor (works like a text edito)
                i
            3) find where it says PasswordAuthentication and change it so that it shows the following:
                PasswordAuthentication yes
            *) Also change PermitRootLogin without-password to 
                PermitRootLogin yes
            4) Click the Esc button to get out of edit mode
            5) Enter the following to write and save the changes
                :w
            6) Enter the following to exit the vi editor
                :q
    9) Open up your SFTP Client and login using the new user you created. The following uses FileZilla:
        1) Open up the Site Manager by click File -> Site Manager
        2) Click New Site
        3) In the General Tab:
            1) Host is the Public DNS of your instance. This can be found by going to the EC2 Dashboard Instances Tab
            2) You can leave the port  and the comments blank
            3) The Protocol is SFTP
            4) The Logon Type is "Ask for password"
            5) The user is root
        4) Click Connect
        5) Enter in the password
            * If there is an unkown host key warning, you can ignore it

Part 4: Install ERPNext on instance
-this will install the ERPNext software on the virtual server which is what your site uses

    1) Open up terminal and ssh into your instance, login to the new user by entering the following:
        su [name]
    2) Type in the following command to download the source and execute
        wget https://raw.githubusercontent.com/frappe/bench/master/install_scripts/setup_frappe.sh
    3) Type in the following command to install
        sudo bash setup_frappe.sh --bench-branch develop
    4) Take note of the MariaDB, Frappe, and Administrator assword
    5) Type in the following command
        bench new-site shaman
    6) Enter in the MariaDB Password when it asks for the MySQL password
    7) Type in the following command
        bench --site [YOUR SITE NAME] install-app erpnext
    8) Type in the following command
        bench start
    *) Note that we are done if everything was operational, now we have to open up the port from amazon
    9) Go to the Amazon EC2 Instance Page
    10) Click on your instance and on the Description tab on the bottom, take not of the Security Groups
    11) Click on the Security Groups on the left hand side
    12) Click on the Security Group for your instance
    13) Click on the Inbound tab for your instance
    14) Click Edit
    15) Add a Custom TCP Rule for Port 8000 and Source 0.0.0.0/0 

Part 5: Finish Up
TODO
8 Likes

Neat! Can you make a Production / Development neutral page on the Bench Wiki once your tutorial is complete?

1 Like

i m finding this error while downloading the package

–2017-01-08 12:54:38-- https://raw.githubusercontent.com/frappe/bench/master/install_scripts/setup_frappe.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)… 151.101.52.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.52.133|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 14251 (14K) [text/plain]
setup_frappe.sh: Permission denied

Cannot write to ‘setup_frappe.sh’ (Success).

where i can find all these password

I am getting this error plz help

WARNING: The following packages cannot be authenticated!
mysql-common mariadb-common libmysqlclient18 libmariadbclient18
mariadb-client-core-10.0 mariadb-client-10.0 mariadb-server-core-10.0
mariadb-server-10.0 libmariadbclient-dev mariadb-server
E: There were unauthenticated packages and -y was used without --allow-unauthenticated

This tutorial mostly works but needs some workarounds. I am leaving these instructions for anyone trying to install ERPnext with this tutorial:
Error 1:
Part 4 Step 3:
sudo bash setup_frappe.sh --bench-branch develop
This shell script gets stuck at:
Installing wkhtmltopdf…

You can run the script with a -v (verbose) and it will tell you that it cannot connect with:
http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb

The reason is because gna[dot]org is shutdown. The workaround is to look for ‘download.gna.org’ in the shell script and replace it with:
https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb

Then the script will run fine and it will install.

Error 2:
Part 4 Step 8:
bench start

Gives an error about PROCFILE.
Solution: You have to go into frappe_bench directory to run this command. It will run fine if you do this.

Hope this helps someone

4 Likes