I’ve decided to provide a quick demonstration of how to create a Bitnami LAMP instance on Amazon Web Services (AWS) ec2 virtual cloud. This tutorial aims to educate public interests on how ostensibly simple website interactions are actually quite complex and easy to take for granted.
The instructions below are from the README file contained within the tutorial-files available at my GitHub repo: aws_example. I’ve also uploaded a screencast to YouTube and Vimeo; I don’t care how derpy I sound so long as it helps others- at least I can write like the wind…
Amazon Web Services
A demonstration of creating an ec2 Bitnami LAMP instance on Amazon Web Services (AWS). Screencast available on YouTube: Amazon Web Services Tutorial.
AWS Console
- Log-in into account.
- Select “EC-2” icon in top-left corner.
- Underneath “Create Instance” (within middle section of page), click the “Launch Instance” button.
Create Instance
- Choose AMI: Upon landing on the first step of the instantiation (Step 1 Choose an Amazon Machine Image (AMI)), search for “LAMP” and select the “LAMP Stack powered by Bitnami” from the results.
- Choose Instance Type: For the sake of this exercise, we will proceed with the “Microinstance”, so just click on the “Review and Launch” button- no other selections are required for free-tier, which means steps 3-6 will be skipped.
- Review: Again, this is a free-tier demo, which means steps 3-6 have been skipped, so just click on the “Launch” button.
- “Launch” will prompt a window with a request to “Select an existing key pair or create a new key pair”; in this example, we will select “Create a new key pair” from the dropdown menu within the window called “awsExample” creating a .pem file (a private key required for Secure SHell (SSH)) which will be downloaded and saved within our local subfolder on our desktop.
- Upon launching, a successful confirmation message should appear within the next page; please select “View Instances” to begin interacting with the Instance from the command-line.
EC2 Dashboard
- After completing the last process, the EC2 Dashboard is now in view. In my screencast, I have two other instances running for academic projects, but let us stick to the example “awsExample” instance (obviously, you could’ve named yours whatever).
- Click on the row within your AWS instance dashboard of the instance name contained within the column “Key Name”.
- A window beneath the Instance table will appear displaying the “PUBLIC DNS address”, which is essentially the URL, or website address, where your instance will be located. Highlight/Copy/Paste and save that URL within a text file; you may view the instance by simply prefixing to the Public DNS then navigating to the browser to test.
- Next, within the console, click on the “Actions” button, hover over “Instance Settings” and then click on “Get System Log”; scroll-down until you see a box outlined in hashtags(#) outlining the text “Setting Bitnami application password to”; copy/paste that password and note that in the text file BUT DO NOT SHARE IT as your instance could potentially be hacked. Now exit the window.
- Click on the “Connect button” and note the following bash scripts; for this exmample the exampled displayed:
ssh -i "aws_example.pem" ubuntu@ec2-52-25-111-159.us-west-2.compute.amazonaws.com
Also click on the Java SSH Client Directly from my browser (Java required) radio button to note the username if you would like to use FileZilla.
The Command-line
- Fire-up your terminal; in the screencast, the iTerm terminal was used. From the root folder ‘~/’ within the user directory, change directories with
cd desktop/aws
. This tut includes a cheatsheet of other UNIX commands for clarification. - Copy/paste the bash script noted in your text-file:
ssh -i "aws_example.pem" ubuntu@ec2-52-25-111-159.us-west-2.compute.amazonaws.com
to successfully log-in into your instance.
- Type in
ls
(list directory) on command-line to list the available folders. Typecd public_html
to change directories into the public_html folder that is served by this instance. If interested, feel free to nano into the ‘index.html’ file to see the code currently rendered on the landing-page of your instance (e.g. nano index.html
) Be sure to exit the file by typing “Control + X” and Type “N” to avoid saving changes.
FileZilla
- Download FileZilla and launch the app.
- Click on the ‘File’ from menu-bar and select ‘Site Manager’.
- In the ‘Site Manager’ window, click-on ‘New Site’ and type your instance-name.
- Copy paste the Public DNS address from your scratch-text-file and input that into the “Host” field.
- Select SFTP – SSH File Transfer Protocol from the dropdown menu.
- Select ‘Normal’ Logon Type.
- Enter ‘ubuntu’ in the ‘User’ field (this was noted earlier in within the step 5 of AWS).
- Clear password field so it’s empty.
- Then click ‘connect’ button which should ensure successful log-in to your AWS instance from FileZilla.
Create a basic form within your Bitnami LAMP instance.
- We will create a basic form to interact with the backend of this Bitnami instance. LAMP is an acronym for the type of application stack delivering this production, which stands for LinuxApacheMySQLPHP. If interested, please read more about it at StackOverlow.
- Download my example files available on GitHub and select the three ‘.php’ files, then drag and drop into the right column representing the AWS directory within the FileZilla window.
- To confirm successful upload, feel free to nano into the ‘login.php’ file- so type
nano login.php
. Now would be an opportune time to copy/paste the Bitnami application password retrieved in step 4 of the ‘EC2 Dashboard’ process; enter that password between the single-quotes. Type ‘CTRL + X’ then type ‘Y’ to save. - Now append ‘/createDB_TBL.php’ to the Public DNS address within the browser address-bar that landed on the ec2 instance to the Public DNS/website address and then go to that address.
- On the front-end, the web-page should display a confirmation but let’s confirm success on the back-end.
- Go back to the terminal and type-in the following to interact with the database:
mysql -u root -p
MySQL
The password entered will be the same password referenced in the ‘login.php’ file, which again was originally derived from step #4 of ‘EC2 Instance’ instructions.
- Congrats- you should be in MySQL! Now type:
show databases
- Type
'use music'
to use the database named in the ‘login.php’ file, which also contains the ‘mymusic’ table specified in the ‘createDB_TBL.php’ file. - Type
desc mymusic
to see the id and corresponding columns which will store that data eventually input. - Type
quit
to exit MySQL - Next, go to your instance page prefixed with /mysqltest.php (e.g. in screencast example it was ”)
- An elementary form should be displayed with fields to input ‘Artist’ and ‘Album’. Have at it! Enter some bangers.
- Type enter and you will see your tunes returned! This means that data is contained within the back-end.
- To verify, go back to the terminal window and type
mysql -u root -p
(remember, copy and paste the password noted in step #6). - Now type
SELECT * FROM music;
- DoofDoof music.
You are now ready to begin exploring the wonderful world of php web development! Feel free to contact me if you wish to chat about all the things. Thanks!