练习在 AWS 的 EC2
上搭建Web服务器。
![EC2](https://upload.wikimedia.org/wikipedia/commons/thumb/b/b9/AWS_Simple_Icons_Compute_Amazon_EC2_Instances.svg/200px-
AWS_Simple_Icons_Compute_Amazon_EC2_Instances.svg.png)
Objective
The objective of this exercise is to:
- Configure web server in cloud
- Create and understand Rest Servers
- Understand and create cloud based backups
Part #1: Set up static IP (Elastic IP)
Exercise
- Shut down your ec2 instance if it is running
* a. Go to the Ec2 dashboard
* b. Select the instance
* c. Select the drop down for instance state to “Stop Instance” - Write down the availability zone of your instance in the dashboard
* a. Mine is us-east-1a for example (use yours not mine) - Select Elastic Ips under Network and Security (on the left)
* a. Select “Allocate Elastic IP Address” (top right)
* b. Make sure the “Network Border Group” matches your instance availability zone from step 2
* c. Click “Allocate”
* d. Should receive a message “Elastic IP Address allocated successfully”
* e. Select the displayed Elastic IP Address (may have to refresh page)- i. Actions dropdown at top right Associate Elastic IP Address
- ii. Resource Type - Instance
- iii. Put your cursor in the Instance text field
1. It will show your stopped instance - select it
1. Click “Associate”
- Start your instance back up a. The IP address shown will now stay the same whenever it is started or stopped
- Update your dynamic DNS from lab 11
Part #2: Protect web directory on your ec2-instance
Exercise
Create basic access control on your web site
- Log into ceclinux and then your ec2-instance
- Update global apache configuration file
* a. sudo vim /etc/httpd/conf/httpd.conf or sudo nano /etc/httpd/conf/httpd.conf
* b. Find the section - Create password file
* a. htpasswd -c ~/.htpasswd USERNAME (make up your own username)
* b. Enter the password
* c. Re-enter the password - Create the apache access control file (requires anyone accessing the website to need the password, except for me to grade)
Part #3: Load Rest Server and Database into cloud
Exercise
- Get archive file cd /tmp
- Test the database using your web admin program
- Verify that the database is accessible
- Paste the “Query used to create this table”from the admin program into your canvas assignment (Find those exact words)
- Test the applications final.php (rest server which adds data to database)
Part #4: Backup (snapshot) your ec2 volume
Exercise
- Log into aws academy
- Go to the ec2 instances - display your running instance
- Select the instance, and right click on the instance id Images and Templates Create Image
- Enter a name for this image
- Press Create Image
This is a good safeguard when you are making operating system changes.
Make a screengrab showing the backup is being made
Do this any time you make operating system changes (any time you use “sudo”)