follow the steps in the attached file
each step is mensioned exactly
this is the link
https://console.aws.amazon.com/console/home
Lab 3:
Distributed Web Server in a VPC
Overview:
In this lab you’ll be launching a distributed web server in a VPC with a public and private subnet. You’ll be given the option to use two different operating systems to create the desired topology. You’ll:
· Create a new VPC
· Launch instances into a private and public subnet
· Create new rules for security groups
· Install a web server
· Install a database server
VPC with Public and Private Subnet
The real power behind Amazon EC2 is that you can duplicate almost any environment that you need at a fraction of the cost to do it with your own equipment. This allows you to turn some of your IT costs from capital investment to operating costs and gives you the flexibility to scale up or scale down as necessary.
To demonstrate a real-world scenario, in this lab you will create a System Administration Wiki in the cloud. You will be using Media Wiki (
http://www.mediawiki.org
). One thing that Media Wiki needs is a database to store all data. However your database should only be accessed by a web server and not be publicly available to everyone else. To accomplish this you will use a VPC with your Wiki server on a public subnet and your database server on a private subnet.
You have the option to use whichever OS you would like. HOWEVER, both machines cannot be the same OS. In the examples given here the Webserver is hosted on a Windows 2008 machine and the database server is on an Ubuntu 12.04 machine.
Creating the VPC
1. Navigate to the VPC Dashboard
2. Create a new VPC and choose the VPC with Public and Private Subnets
3. The following screen gives you a summary of the actions that the VPC will do for you. Notice that it will launch a NAT Instance. In order for your webserver to talk to your private subnet it will need an instance that works as a Network Address Translator to pass traffic between the two subnets.
NOTE THE KEY PAIR IT’S USING AND THE AVAILABILITY ZONE!!!! IF YOU DON’T USE THE RIGHT KEY PAIR YOU WON’T BE ABLE TO CONNECT TO YOUR INSTANCES AND WILL HAVE TO DELETE EVERYTHING AND START OVER!
4. When your VPC is created right down it’s ID. If you can’t tell which one was just created, go to your EC2 instances and check the VPC-ID of the machine that is current launching.
5. Once you have identified the VPC, go to the subnets list and write down the subnet IDs of the two new subnets. Note which one is your Public Subnet and which is the Private Subnet. In this example we identified the network 10.0.0.0/24 as the public subnet and 10.0.1.0/24 as the private subnet. This is important for when you’re going to launch your instances.
6. Launch your webserver into your public subnet and launch your database server into your private subnet. Note that you now have VPC Advanced Options to identify the IP address that you want your instances to use. Identify one.
7. You’ll also have to identify new security groups like we did in the previous lab
When you launch your database instance make sure to add a rule that allows MySQL connections.
8. You need to associate an elastic IP address to your web server so you can log in to it. Remember there is no public DNS created for the instance. You can’t assign an elastic IP to your database server. You are going to have to log in to that machine through your web server.
Installing the servers
Because the installation varies based on the machines that you choose, the remaining instructions are very brief and only gives general steps.
1. Now log on to your webserver and download the install packages for MediaWiki. Review the installation process carefully!!! Look at the necessary requirements for installation such as PHP and the database servers that are compatible with the software. When you extract the install package make sure to extract it to the public folder of the web server. In Windows this would be \inetpub\wwwroot
2. Before starting the installation make sure that your database server has MySQL (or whatever database you chose) installed. Create the database prior to starting the MediaWiki Installation
Note: Make sure the OS allows for remote connections to your database. Also make sure that the user that you will be using to connect to your database is given permission to do so from remote locations, this is a database permission not an OS permission.
3. Use the installation guide on the MediaWiki pages (
http://mediawiki.org
) to start your installation.
4. When you get to the screen where you have to select your database server put in the IP address of your database server. If you have set up the rules on your database server correctly the installation will continue. If you get an error at this step look at the permissions as mentioned in step 11 and also review the rules in your security groups
Deliverables:
· Screenshot of your VPC
· The IDs of your VPC, subnets, DHCP option sets, Internet Gateways, and Security groups
· Screenshot of tables created by MediaWiki like below
· Screenshot of the main page of your Wiki site
issues
Connecting to your Database server
Because your server is in the private subnet you are going to have to use another machine in the public subnet to connect to it. For this lab you can use your web server to do it. However ideally you would be using another machine so that your webserver doesn’t have one more role to perform and for security reasons.
The biggest issue in connecting is getting your key pair to authenticate to your database server. If your database server is a Windows machine then this is a simpler task because all you need is to get the Administrator password from the EC2 instances page. However if your machine is a Linux box then you need to find a way to get a copy of your keypair file to the machine in your public subnet that will be connecting to your database. This can get tricky but it does work out. There are various options for doing this. If you use a windows machine as a webserver you can use Putty to SSH into your database (which will be a Linux or Unix box) using the these instructions:
http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/putty.html
If you are using a Unix and Linux box you can use scp (Secure copy) to copy the keypair from your local machine to the cloud.
Linux Boxes
First remember that any commands that have you editing files in /sbin or /etc will most likely require you to use the ‘sudo’ command in order to be able to write to those read-only files.
If you get an error like ‘unable to resolve host ip-XX-XX-XX-XX’ this means that there is something that needs to be changed in the /etc/hostname or /etc/hosts file. The hosts file should look something like this:
naming
Make sure that as soon as you create an instance you name it. Remember you are not the only one using the system and there will be multiple instances running. Use your initials or if working on a team append a part of your team (like Team A:T-A) to the name of your instances. This will help you when you need to monitor a machine or delete an instance.