EC2

Setting Up EC2 Instance

  1. Go to AWS Console
  2. Click EC2
  3. Click instance in the left side menu.
  4. Click Launch instance at the top right.
  5. Pick your server of choice, generally the first Ubuntu that appears in the list.
  6. Choose the default, usally free tier instance unless you have a reason to choose otherwise. Then click Next: Configure instance details at the bottom right.
  7. Leave configure instance details as default, click next until you arrive at configure security group.
  8. Add rules for SSH, HTTP and HTTPS to be accessed from source: Anywhere.
  9. Click next and then launch. It will prompt you to select or create a new key pair, create if you dont have one. Name it as you wish but keep the name simple. I will use: “exampleec2”. Click download key pair and put the .perm file somewhere safe.
  10. Once the key is donwloaded, click Launch at the bottom right. Then once launched click view instances.
  11. Click on the instance id then copy the Public IPv4 DNS address, or the IP, but generally the one that looks like a URL: ec2-3-83-212-13.compute-1.amazonaws.com.

** FOR WINDOWS USERS **

  1. Download and install putty from here: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
  2. Find puttygen in the start menu and open it.
  3. Click load, navitate to the folder with the .perm file in it, change the file types from .ppk to all and open the .perm file. Click save private key once it has loaded. Passphrase is better for security, but not always needed. Exit out, now a .ppk file has been created.
  4. Find putty in the start menu and open it.
  1. Insert the address, ec2-3-83-212-13.compute-1.amazonaws.com in the host name along with the SSH port number, 22, in the port number.
  2. Go to SSH in the category menu on the left, then go to auth, then where it says private key file for authenitcation and click browse and find the .ppk file that was saved.
  3. Go back to session and choose the save option to save this setting with a name created under saved sessions, ala exampleec2.
  4. Click open to access the terminal of your ec2 server. Click ‘yes’ at teh security alert and then type ‘ubuntu’ as the password, or whatever the default password for your server distro choice is.

The server is set up at this point, and you have access to what is effectively the command prompt.

**

Setting up Software on EC2 Instance

More often than not we will want the server to run whether we have SSH’d into the server or not. For this we will use tmux. There is a great cheatsheat of tmux commands here: https://tmuxcheatsheet.com/.

  1. Type ‘tmux new -s mysession’ into the terminal. shift + insert is your friend for copy-pasting into the terminal. You can change the name from ‘mysession’ to whatever you want.
  2. Type ‘sudo apt-get update’ to make sure the linux packages are up to date.

Whenever you want to access the session again, type ‘tmux a -t mysession’.

At this point you can start installing software just like you would from the command prompt on your own PC.

Setting up Jupyter Notebook/Lab on EC2 Instance

//This section is under construction.

  1. Type ‘sudo apt-get install build-essential cmake g++ gfortran git vim pkg-config python-dev software-properties-common wget’ and select yes at the prompt.
  2. Type ‘sudo apt install python3-pip’ and select yes at the prompt.
  3. pip3 install pandas numpy flask scikit-learn jupyter jupyterlab werkzeug
  4. nano ~/.bashrc
  5. export PATH=”$HOME/.local/bin:$PATH”Y
  6. jupyter notebook –generate-config
  7. cd to the directory and open with nano and then paste:
  8. c.NotebookApp.ip = ‘*’
  9. jupyter-lab –ip=0.0.0.0 –port=9999

Setting up Webserver in EC2 Instance