Programming Fundamentals I: Ryan Waliany
Programming Fundamentals I: Ryan Waliany
Getting Started
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that enables you to launch and manage Linux/UNIX and Windows server instances in Amazons data centers. You will be using the AWS Management Console which is a point-and-click web-based interface.
Launch Instance
3 1. Sign in to the AWS Management Console and open the Amazon EC2 console at http://console.aws.amazon.com/ec2/ 2. From the Amazon EC2 console dashboard, click Launch Instance. 3. Select a name for your instance, such as Web Server. 4. Create a key pair by entering a name and clicking download. Save the le to a safe location as it is a key to your house on the internet. 5. Under the Quick Launch Wizard, select Ubuntu Server 12.04 LTS and click continue.
Important Verify that you see t1.micro as the machine type since this is the only server size that qualies for the Free Usage Tier.
1. To connect to your instance, right-click the server row and click Connect.
2. Select Connect from your browser using the Java SSH (Secure Shell) Client. You will be asked for the username, which you should change to ubuntu and the private key path. The private key path will be wherever you saved your key.
3. Write down your hostname. In the screenshot above, the hostname is ec2-50-112-39-111.us-west-2.compute.amazonaws.com.
Congratulations! If youve reached this step, you have successful started your rst Linux server and connected to it!
6 mv <source> <destination> - move le from the source to the destination location. rm <le> - remove le. sudo <command> - execute a command with administrator powers. sudo apt-get update - updates the list of packages for installation as administrator. sudo apt-get install <package> - installs a package as administrator. nano <le> - text editor program similar to notepad in shell.
To get started, type the following commands (in bold) into the shell followed by enter. sudo apt-get update sudo apt-get install apache2 php5 - It calculates the dependencies and list of all packages to be installed. Type Y to proceed followed by an enter.
In this section, we will change our current working directory to the directory that contains the website. We will open the website in a text editor and we will add our own message to it! Please execute the following commands in bold.
sudo nano index.html - open up the text editor for index.html. Add the text <p>I just wrote my rst line of html</p> just before </body>. Press ctrl and x at the same time, then press y, then hit enter. This will save and exit the nano program.
Your website should be up and running, but you wont be able to access it from your home computer. This is because Amazon, by default, has an extremely strict internet policy (rewall). In your web browser on the Amazon Web Console screen, perform the following actions: Click Security Groups on the left-hand side Click the quick-launch policy. In the bottom tab, select Inbound. Enter 80 in the Port Range eld, click Add Rule, and then click Apply Rule Change. To see your website, enter your hostname in a web browser and it should work!
In this section, we will change our HTML le to a PHP le by simply renaming it. Once weve renamed it, we will edit the le again using nano and add some PHP code. ls - check to see that index.html is present sudo mv index.html index.php - move index.html to index.php ls - check to see that index.php is present sudo nano index.php - open up the text editor for index.php. Add the text <?php echo I just wrote my rst computer program!; ? > just before </body>. Press ctrl and x at the same time, then press y, then hit enter. This will save and exit the nano program. To see your rst computer program, refresh your web browser!
Additional Resources
http://docs.amazonwebservices.com/AWSEC2/latest/GettingStartedGuide/Welcome.html http://php.net/manual/en/tutorial.php