The scripts provided in this article are not the recommended instance configurations because they have literally no security. Anyone in the world could technically request coffee or worse. We left out security configurations / API keys, etc., to keep the tutorial as simple as possible.

We need a way for customers to tell TurtleBot that they want coffee and manage the coffee queue if multiple people want coffee simultaneously. There are multiple ways to do this, but considering this series is targeted at web developers, we’ll use a LAMP stack.

What is LAMP?

LAMP is an acronym for Linux, Apache, MySQL and PHP. In other words, it includes everything you need to run a web server and a database.

Creating a Web Server

You could create a local web server and have customers connect to that. But, instead of converting an existing computer to a web server, let’s spawn an instance in the cloud.

Amazon web services (aka: “AWS”) offers free micro-size Ubuntu web servers for 1 year. You’ll need to type in your credit card number but as long as you cancel in the first year and don’t use more resources than offered in their free plan your card will not be charged.

If you don’t already have an AWS account, click “Create Free Account” on this page. Once you’ve finished signing up, click “Launch Management Console”.

Creating Your CoffeeBot’s AWS Instance

Uubuntu Instance on AWS

  1. Log in to the AWS management console.
  2. Click “EC2″.
  3. Click “Launch Instance” button.
  4. Select “Ubuntu Server 14.04″. (Tip: This is the same distribution of Linux on your computers, so it should act similarly.)
  5. Select “t2 micro”. (Tip: Make sure it says “free tier eligible” so you won’t be charged.)
  6. Next: “Configure Instance Details”.
  7. “Review and Launch”.
  8. By default HTTP is off. Without this no one can access your server via a web browser.
    • Under “Security Groups” click “Edit Security Groups” and select “Add Rule”.
    • From the pulldown menu select “HTTP”.
    • Click “Review and launch”.
  9. Select “Launch”.
  10. A key pair will give you the credential file required to SSH into your server.
    • Create a new key pair.
    • Key pair name “turtlebot_new”
    • “Download Key Pair”
    • Save it in your downloads folder.
  11. Click “Launch Instances”.
  12. Select “View Instances”.

Determining Your Public DNS

Your instance’s public DNS is how your customers (and TurtleBot) will connect to the server. Let’s go ahead and copy it for later use.

Determing Your EC2 Instance's Public DNS

  1. Log in to the AWS management console.
  2. Click “EC2″.
  3. Click “Running Instances”.
  4. Select the checkbox to the left of the instance.
  5. The “Public DNS” value is available at the bottom right.

TIP: We haven’t installed the LAMP stack on your server yet, so if you call the IP, nothing will happen.

SSH in to AWS Instance

Web Server (EC2 + Ubuntu)

IMPORTANT: Change [PUBLIC_DNS] to the value you copied earlier.

In a terminal window run the following:

cd ~/Downloads
chmod 400 turtlebot_new.pem
ssh -i turtlebot_new.pem ubuntu@[PUBLIC_DNS]

When it prompts:

Are you sure you want to continue connecting (yes/no)?

Type yes.

Installing the LAMP Stack

Shell (ssh) in to your server, then run the following commands:

sudo apt-get update

Install Apache

sudo apt-get install apache2

Install MySQL

sudo apt-get install mysql-server php5-mysql

When prompted, set the root password of MySQL to “turtlebot”.

TIP: This is a terrible password, so feel free to set it to another value–but you’ll need to modify the config.php file cloned from github in a later step.

Install PHP

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

Give Ubuntu user rights to /var/www/

sudo adduser ubuntu www-data
sudo chown -R www-data:www-data /var/www
sudo chmod -R g+rw /var/www

Restart Apache

service apache2 stop
service apache2 start

NOTE: In the video we tried service apache2 restart but this fails. stop and start succeeds.

Clone PHP files

cd /var/www/html
sudo apt-get install git
sudo git clone

NOTE: In the video I first tried “git clone” without “sudo”; “sudo” is required.

Install LAMP Stack on TurtleBot Server

Clone Web App

The web app is very similar to the browser extension but will allow your customers to request coffee directly from their smartphone. We’ll discuss this in more detail later, but for convenience let’s go ahead and clone it as well.

cd /var/www/html
sudo git clone

(Optional) Set MySQL root password

If you didn’t set the MySQL root password to “turtlebot”, you need to edit the configuration file. If you did set the MySQL root password to “turtlebot”, skip this section.

cd /var/www/html/turtlebot-server/
nano config.php

Scroll down to:

$a["password"] = "turtlebot"; //mysql password

and update the value.

Then ctrl + x to exit and y to save.