官术网_书友最值得收藏!

How to do it...

  1. Log in to your AWS account. Select EC2 services as shown in the following figure:
 
 Select EC2 service
  1. The EC2 dashboard will appear. Click on Launch Instance in the EC2 dashboard.
 EC2 dashboard
  1. Select Amazon Linux AMI, which is available on the top of the list
Choose AMI
  1. There are many instance types available with different vCPU and memory options. We shall choose t2.micro and then click on Next: Configure Instance Details.

 Choose instance type
  1. In Network, choose the VPC we just created. In Subnet, select the subnet we created. In Auto-assign Public IP, choose Enable. In Auto-assign IPv6 IP, choose Enable. Click on Next: Add Storage.
Choose network
  1. Click on the Advanced Details and put the following lines in the text box. This is user data. This may vary with the OS  of EC2. The script is executed when the instance is first created. Here is a script that can execute on Linux. It will install Apache, PHP, and MySQL in the server. It will also start the Apache server once the EC2 is running.
#!/bin/bash
yum update -y
yum install -y httpd24 php56 mysql55-server php56-mysqlnd
service httpd start
chkconfig httpd on
groupadd www
usermod -a -G www ec2-user
chown -R root:www /var/www
chmod 2775 /var/www
find /var/www -type d -exec chmod 2775 {} +
find /var/www -type f -exec chmod 0664 {} +
echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php
  1. Accept the default option and click Next: Add Tags
 Add Storage
  1. Click on Add Tags. In Key, put Name and in Value, put MyFirstEC2. Click on Next: Configure Security Group.
 Add Tags
  1. Provide a Security group name and Description. By default, SSH is open to all IP addresses. In Source, we have two CIDR ranges, 0.0.0.0/0 to allow all IPv4 addresses and ::/0 to allow all IPv6 addresses. Click on Add Rule and allow HTTP traffic to all source. We should not be opening our servers to all like this, however for simplicity, let's do this for now. Click on Review and Launch.
 Configure Security Group
  1. Review the details and click Launch.
 Review instance launch
  1. We can optionally create a key pair. Key information is required if we want to log into EC2. Download Key Pair and store it in a safe place. Click on Launch Instances.
 Create Key Pair
  1. You can see a success message with the EC2 instance ID. Click on the ID. It will take us to the EC2 console. The instance will be in running condition in some time.
 EC2 launch status
  1. We can see both Public DNS (IPv4) and IPv6 IPs. We can create URL to access page running on EC2: http:// DNS(IPv4)/phpinfo.php. Replace the DNS (IPv4) in the URL with the one you see in the console. Open a browser and paste the URL.
 EC2 instance detail
  1. We can see the page of the server we created on the EC2 instance.

Sample web page on EC2
主站蜘蛛池模板: 大足县| 日土县| 黎平县| 江都市| 新绛县| 灵武市| 临桂县| 崇义县| 密山市| 霸州市| 禄丰县| 凤凰县| 内乡县| 铜山县| 景东| 祁阳县| 洪泽县| 两当县| 荣成市| 邢台县| 涿鹿县| 大竹县| 丘北县| 宽甸| 驻马店市| 古浪县| 大方县| 科技| 双牌县| 海晏县| 广汉市| 望都县| 建昌县| 大同县| 大丰市| 安塞县| 曲阳县| 大洼县| 绥滨县| 泰宁县| 平度市|