864
Amazon Elastic Compute Cloud Linux 实例用户指南

Amazon Elastic Compute Cloud - AWS Documentation · Amazon Elastic Compute Cloud Linux 实例用户指南 Table of Contents 什么是 Amazon EC2?..... 1

  • Upload
    dominh

  • View
    264

  • Download
    0

Embed Size (px)

Citation preview

  • Amazon Elastic Compute CloudLinux

  • Amazon Elastic Compute Cloud Linux

    Amazon Elastic Compute Cloud: Linux Copyright 2018 Amazon Web Services, Inc. and/or its affiliates. All rights reserved.

    Amazon's trademarks and trade dress may not be used in connection with any product or service that is not Amazon's, in any mannerthat is likely to cause confusion among customers, or in any manner that disparages or discredits Amazon. All other trademarks notowned by Amazon are the property of their respective owners, who may or may not be affiliated with, connected to, or sponsored byAmazon.

  • Amazon Elastic Compute Cloud Linux

    Table of Contents Amazon EC2 ........................................................................................................................ 1

    Amazon EC2 ................................................................................................................... 1 Amazon EC2 .......................................................................................................... 1 .................................................................................................................................... 2 Amazon EC2 ...................................................................................................................... 3Amazon EC2 ...................................................................................................................... 3PCI DSS ......................................................................................................................... 4 AMI ................................................................................................................................ 4

    .................................................................................................................................. 4AMI .................................................................................................................................. 5

    ............................................................................................................................. 6 ............................................................................................................... 6 ............................................................................................................................... 7 .................................................................................................................. 8 ......................................................................................................... 8 ................................................................................................................. 10 .......................................................................................................... 11 .................................................................................................... 12

    .................................................................................................................................. 12 ................................................................................................................. 12 AMI .................................................................................................... 14 ....................................................................................................... 14 ................................................................................................. 15

    ................................................................................................................................................ 17 AWS ................................................................................................................................ 17 IAM .......................................................................................................................... 17 ............................................................................................................................... 18 Virtual Private Cloud (VPC) ................................................................................................. 21 ............................................................................................................................... 21

    ................................................................................................................................................ 24 ........................................................................................................................................ 24 .................................................................................................................................. 25 1 ...................................................................................................................... 25 2 ............................................................................................................. 26 3 ................................................................................................................ 26 .................................................................................................................................. 27

    .......................................................................................................................................... 28 ................................................................................................................................................ 29

    LAMP (Amazon Linux 2) .......................................................................................... 29 1 LAMP ................................................................................................ 29 2 LAMP ................................................................................................ 32 3 ........................................................................................ 33 4() phpMyAdmin ........................................................................................ 34 .......................................................................................................................... 37 .......................................................................................................................... 37

    LAMP (Amazon Linux AMI) ....................................................................................... 37 .......................................................................................................................... 37 .......................................................................................................................... 37

    WordPress ....................................................................................................... 47 .......................................................................................................................... 47 WordPress ................................................................................................................ 48 .......................................................................................................................... 53 DNS ............................................................ 54

    Amazon Linux 2 Apache Web SSL/TLS .......................................... 55

    iii

  • Amazon Elastic Compute Cloud Linux

    .......................................................................................................................... 55 1 SSL/TLS ....................................................................................... 56 2 CA .............................................................................................. 57 3 .............................................................................................. 61 .......................................................................................................................... 63 Amazon Linux 2 Let's Encrypt Certbot ............................................ 64

    ...................................................................................................... 68 .......................................................................................................................... 68 ........................................................................................... 69 ................................................................................................................. 70

    ............................................................................................................ 70 Systems Manager ............................................................. 71 SSM ................................................................................................................. 71 EC2 .................................................................................................. 71 Windows PowerShell AWS ....................................................... 72 AWS CLI .................................................................................................... 73 .......................................................................................................................... 73

    Amazon ............................................................................................................................. 75 AMI ................................................................................................................................. 75 AMI ..................................................................................................................... 75 AMI ............................................................................................................... 75 AMI ..................................................................................................................... 76Amazon Linux 2 Amazon Linux AMI ........................................................................................ 76AMI ................................................................................................................................. 76

    .......................................................................................................................... 76 ....................................................................................................................... 77

    ............................................................................................................................... 78 Linux AMI ......................................................................................................................... 79

    Amazon EC2 Linux AMI ............................................................................. 80 AWS CLI AMI .................................................................................................... 80

    AMI ................................................................................................................................. 81 AMI ................................................................................................................... 81 AMI ............................................................................................................... 83 AMI AWS ............................................................................................. 84 .......................................................................................................................... 85 Linux AMI ................................................................................................... 86

    AMI ................................................................................................................................. 89 AMI ......................................................................................................................... 90 AMI ................................................................................................................... 90 AMI ................................................................................................................... 91 .......................................................................................................... 91 .................................................................................................................... 91 AMI ...................................................................................................... 92 AWS Marketplace ............................................................................................... 92

    Amazon EBS Linux AMI ........................................................................................... 92 Amazon EBS AMIs ................................................................................ 93 Linux AMI ........................................................................................................ 93 Linux AMI ........................................................................................................ 95

    Linux AMI ................................................................................................ 95 AMI ................................................................................ 96 .......................................................................................................................... 96 AMI .................................................................................................................. 97 AMI ....................................................................................... 99 Amazon EBS AMI ....................................................................................... 106AMI ................................................................................................................. 109

    AMIs .................................................................................................................. 124 EBS AMI ...................................................................................... 124

    iv

  • Amazon Elastic Compute Cloud Linux

    AMI ................................................................................................................................ 127 AMI ........................................................................................ 127 AMI ............................................................................................................. 128 AMI ............................................................................................................. 128 AMI ............................................................................................................. 129 AMI ........................................................................................................................ 130 AMI .............................................................................................. 131

    Linux AMI ........................................................................................................... 131 Amazon EBS AMI ....................................................................................... 132 AMI ............................................................................................... 132

    Amazon Linux ......................................................................................................................... 133 Amazon Linux ............................................................................................... 133 Amazon Linux .................................................................................................. 134AWS ............................................................................................................. 135 .................................................................................................................. 135Extras (Amazon Linux 2) .............................................................................................. 137 ................................................................................................ 138cloud-init ........................................................................................................................ 138 Amazon Linux .................................................................................................. 139 Amazon Linux 2 ................................................................................. 140

    ....................................................................................................................... 143HVM AMIs (GRUB) ......................................................................................................... 143 AMIs (PV-GRUB) ............................................................................................... 144

    .............................................................................................................................................. 149 ................................................................................................................................ 149

    .................................................................................................................. 150 ........................................................................................................................ 151 ..................................................................................................................... 151 ............................................................................................................... 151 ........................................................................................................................ 153T2 ......................................................................................................................... 153 ........................................................................................................................ 173 ............................................................................................................... 176 ............................................................................................................... 179 ............................................................................................................... 183 .................................................................................................................. 188T1 ................................................................................................................... 196 .................................................................................................................. 207 CPU ............................................................................................................... 210

    .......................................................................................................................... 215 .................................................................................................................. 215 ........................................................................................................................ 216 ........................................................................................................................ 246Spot ....................................................................................................................... 249 ........................................................................................................................ 297 ........................................................................................................................ 309

    .......................................................................................................................... 313 ........................................................................................................................ 314 ( Amazon EBS ) .................................................................. 315 ........................................................................................................................ 315 ........................................................................................................................ 315 ........................................................................................................................ 315 ............................................................................................. 316 .............................................................................................................................. 316 .............................................................................................................................. 352 ..................................................................................................................... 369 .............................................................................................................................. 371

    v

  • Amazon Elastic Compute Cloud Linux

    .............................................................................................................................. 372 .............................................................................................................................. 373 .............................................................................................................................. 378

    ................................................................................................................................ 379 .................................................................................................................. 379 ........................................................................................................................ 380 ........................................................................................................................ 384 ............................................................................................................... 385 ........................................................................................................................ 390 ..................................................................................................................... 394 DNS ................................................................................................................ 397 ............................................................................................................... 398 ...................................................................................................... 403

    ................................................................................................................................ 416 UUID ............................................................................................................... 416 ............................................................................................................ 417

    .............................................................................................................................................. 418 ....................................................................................................................... 418

    .................................................................................................................. 419 .................................................................................................................. 419

    ....................................................................................................................... 420 .......................................................................................................................... 420

    .................................................................................................................. 421 ..................................................................................................................... 425

    CloudWatch ................................................................................................. 428 .................................................................................................................. 428 .................................................................................................................. 430 ......................................................................................................... 437 .................................................................................................................. 444 ........................................................................................................................ 444 ............................................................................. 445

    CloudWatch Events Amazon EC2 .................................................................. 453 ................................................................................................................. 453

    CloudWatch ............................................................................................... 453CloudWatch ...................................................................................................... 453

    .................................................................................................................................. 462 ................................................................................................................................... 462

    Amazon EC2 .......................................................................................... 463 Amazon EC2 ............................................................................... 464 Linux ...................................................................................... 465 Windows ................................................................................. 466 ............................................................................................. 466 ......................................................................................................... 466 ............................................................................................................... 467 ................................................................................................... 467 Linux ...................................................................................... 468

    ................................................................................................................................... 470EC2-Classic ......................................................................................................... 471EC2-VPC ............................................................................................................. 471 ..................................................................................................................... 471 ..................................................................................................................... 473 .................................................................................................................. 474 ..................................................................................................................... 474 ............................................................................................................... 478

    ................................................................................................................................ 483 ............................................................................................................ 484Amazon EC2 ..................................................................................................... 484

    vi

  • Amazon Elastic Compute Cloud Linux

    IAM Amazon EC2 ....................................................................................................... 484IAM ........................................................................................................................ 485IAM ........................................................................................................................ 555 ........................................................................................................................ 563

    Amazon VPC .......................................................................................................................... 565 VPC ............................................................................................................ 565EC2-Classic EC2-VPC ........................................................................................ 566 EC2-Classic EC2-VPC ................................................................ 568 VPC ................................................................................................ 570Amazon VPC .......................................................................................................... 570 ..................................................................................................................... 570ClassicLink ..................................................................................................................... 571 EC2-Classic VPC ............................................................................................. 581

    IP ........................................................................................................................... 590 IPv4 DNS ..................................................................................... 590 IPv4 DNS ..................................................................................... 591 IP (IPv4) ......................................................................................................... 592Amazon DNS ....................................................................................................... 592IPv6 ....................................................................................................................... 592EC2-Classic EC2-VPC IP ..................................................................... 593 IP .......................................................................................................... 593 IP ................................................................................................................... 597

    IP ........................................................................................................................... 604 IP ....................................................................................................... 604EC2-Classic EC2-VPC IP .................................................................. 605 IP ............................................................................................................. 606 DNS .................................................................................... 611 IP ............................................................................................................. 612

    ................................................................................................................................ 612 ............................................................................................................ 612 IP .............................................................................. 613 ......................................................................................................... 617 ...................................................................................................... 618 .................................................................................................................. 620 ...................................................................................................... 627

    ................................................................................................................................ 628 .................................................................................................................. 629 .................................................................................................................. 629 ......................................................................................................... 629 .................................................................................................................. 630 ...................................................................................................... 630 ......................................................................................................... 631 .................................................................................................................. 632

    MTU .............................................................................................................................. 632 (9001 MTU) ......................................................................................................... 633 MTU ............................................................................................................... 633 MTU ........................................................................................... 633 Linux MTU ................................................................................. 634 ........................................................................................................................ 635

    ................................................................................................................................ 635 .................................................................................................................. 635 ...................................................................................................... 635Intel 82599 VF .......................................................................................... 635ENA ......................................................................................................... 643ENA ................................................................................................................. 651

    .............................................................................................................................................. 658Amazon EBS .......................................................................................................................... 659

    vii

  • Amazon Elastic Compute Cloud Linux

    Amazon EBS ....................................................................................................... 660EBS .......................................................................................................................... 660EBS ....................................................................................................................... 713EBS ....................................................................................................................... 721EBS ....................................................................................................................... 727EBS NVMe ............................................................................................................. 731EBS ....................................................................................................................... 732EBS CloudWatch Events .................................................................................................. 745

    ................................................................................................................................ 752 ............................................................................................................ 753 ..................................................................................................................... 753 ............................................................................................................... 756SSD .............................................................................................................. 758 ............................................................................................................... 759 .................................................................................................................. 761

    Amazon EFS .......................................................................................................................... 762 ........................................................................................................................ 762 1 EFS .............................................................................................. 762 2 ...................................................................................................... 763 3 ...................................................................................................... 764 4 .................................................................................................................. 764

    Amazon S3 ............................................................................................................................ 765Amazon S3 Amazon EC2 ............................................................................................. 765

    ............................................................................................................................. 766 Linux ..................................................................................................... 766 Windows ................................................................................................ 767 .................................................................................................................. 767 ..................................................................................................................... 767

    ................................................................................................................................ 767 .................................................................................................................. 768 ............................................................................................................ 768

    ....................................................................................................................... 769 ...................................................................................................... 769AMI ........................................................................................................ 771 ......................................................................................................... 773

    ....................................................................................................................... 776 ............................................................................................................... 777 ............................................................................................................... 777 ................................................................................................... 777 ................................................................................................... 778

    ..................................................................................................................................... 779 ................................................................................................................................ 779 ID .................................................................................................................................. 780

    ID ................................................................................................................. 781 ID ................................................................................................ 784

    ................................................................................................................. 784 ........................................................................................................................ 785 ......................................................................................................... 786 ......................................................................................................... 786 CLI API .............................................................................................. 787

    ................................................................................................................................ 787 ......................................................................................................... 788 ............................................................................................................ 789 ........................................................................................................................ 790 ......................................................................................................... 791 ......................................................................................................... 791 CLI API ................................................................................................. 794

    viii

  • Amazon Elastic Compute Cloud Linux

    ................................................................................................................................ 795 .................................................................................................................. 795 .................................................................................................................. 796

    ............................................................................................................................. 797EC2Rescue for Linux ....................................................................................................................... 798

    EC2Rescue for Linux ....................................................................................................... 798 EC2Rescue for Linux ....................................................................................................... 799

    ........................................................................................................................ 799 ........................................................................................................................ 799 ........................................................................................................................ 800 ........................................................................................................................ 800

    EC2Rescue ............................................................................................................. 801 .................................................................................................................. 801 .................................................................................................................. 803 YAML ............................................................................................................. 804 ........................................................................................................................ 804

    ........................................................................................................................................ 806 .......................................................................................................................... 806

    .................................................................................................................. 806 .................................................................................................................. 806 .................................................................................................................. 807

    ....................................................................................................................... 808 ...................................................................................... 808 ......................................................................................... 810 (publickey) ..................... 811 ................................................................................................... 812 ....................................................... 813 Safari MindTerm ............................................................................ 813 macOS RDP ........................................................................................ 813 Ping ................................................................................................ 814

    ................................................................................................................................ 814 .................................................................................................................. 814

    ................................................................................................................................ 815 ............................................................................................................... 815 ......................................................................................................... 815 ......................................................................................................... 816

    .......................................................................................................................... 816 .......................................................................................................................... 816

    ........................................................................................................................ 817 .................................................................................................................. 817 Linux ................................................................................ 817 ......................................................................................................... 818mmu_update () ....................................................................... 819I/O () ................................................................................................ 819I/O ................................... 821request_modulerunaway loop modprobe ( Linux modprobe) ........... 821fsck /dev ( AMI ) ........... 822FATAL: Could not load /lib/modulesBusyBox() ......................................... 823ERROR (EC2 ) ................................................................................ 824request_modulerunaway loop modprobe( Linux modprobe) ............ 825fsck... () ................................................... 826 () .......................................................................... 827VFS fs () .............................................................. 828/...(/) ................................................. 829XENBUS ......................................................................................... 830 () ................................................. 831fsck ...() ........................................................................................... 831

    ix

  • Amazon Elastic Compute Cloud Linux

    GRUB (grubdom>) ................................................................................................... 832 eth0 eth0 MAC ( MAC ) ................... 834 SELinux (SELinux ) ................... 835XENBUS (Xenbus ) ........................................................................... 836

    ........................................................................................................ 836 ........................................................................................................................ 836 ............................................................................................................... 837 ......................................................................................... 837 ................................................................................................ 838

    ................................................................................................................. 838 .................................................................................................................................. 840AWS ................................................................................................................................... 854

    x

  • Amazon Elastic Compute Cloud Linux Amazon EC2

    Amazon EC2Amazon Elastic Compute Cloud (Amazon EC2) Amazon Web Services (AWS) Amazon EC2 AmazonEC2Amazon EC2

    Amazon EC2 Amazon EC2

    Amazon (AMI) (

    ) CPU (AWS ) () Amazon Elastic Block Store (Amazon EBS) Amazon EBS Amazon EBS IP IPv4 IP Amazon EC2 AWS

    Virtual Private Cloud (VPC)

    Amazon EC2 Amazon EC2

    AWS Web

    Amazon EC2 Amazon EC2 Amazon EC2 Amazon EC2

    Amazon EC2 (p. 17) Amazon EC2 Linux (p. 24)

    AMI (p. 4)

    1

    https://aws.amazon.com/what-is-cloud-computing/https://aws.amazon.com/ec2https://aws.amazon.com/websites/

  • Amazon Elastic Compute Cloud Linux

    (p. 6) (p. 149) (p. 787)

    Amazon EC2 (p. 462) (p. 470) IP (p. 604) Amazon EC2 Amazon VPC (p. 565)

    Amazon EBS (p. 659) (p. 752)

    Linux

    (Run Command) Amazon Linux 2 LAMP Web (p. 29) Amazon Linux 2 Apache Web SSL/TLS (p. 55) AWS Linux Web

    AWS AWS Amazon EC2 Amazon EC2 forum

    Amazon EC2 Amazon EC2 AWS Amazon EC2

    Amazon EC2 Auto Scaling AWS CloudFormation AWS Elastic Beanstalk AWS OpsWorks

    Elastic Load Balancing ElasticLoad Balancing

    Amazon EBS Amazon CloudWatchAmazon CloudWatch

    Amazon EC2 Lambda AWS SSM Run Command Amazon CloudWatch Events AmazonCloudWatch Events

    Amazon EC2 API ( AWS ) AWS CloudTrail AWS CloudTrail User Guide

    2

    http://docs.aws.amazon.com/systems-manager/latest/userguide/execute-remote-commands.htmlhttp://docs.aws.amazon.com/gettingstarted/latest/wah-linux/https://aws.amazon.com/contact-us/https://forums.aws.amazon.com/forum.jspa?forumID=30http://docs.aws.amazon.com/autoscaling/latest/userguide/http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/http://docs.aws.amazon.com/opsworks/latest/userguide/http://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/http://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/http://docs.aws.amazon.com/AmazonCloudWatch/latest/events/http://docs.aws.amazon.com/AmazonCloudWatch/latest/events/http://docs.aws.amazon.com/awscloudtrail/latest/userguide/

  • Amazon Elastic Compute Cloud Linux Amazon EC2

    Amazon Relational Database Service (Amazon RDS) EC2 Amazon RDS Amazon Relational Database Service

    (VM) AWS AMI VMImport/Export VM Import/Export

    Amazon EC2Amazon EC2 Web Amazon EC2 AWS AWS EC2 Amazon EC2

    AWS (CLI)

    AWS WindowsMac Linux AWS Command Line Interface Amazon EC2 AWS CLICommand Reference ec2

    Windows PowerShell AWS

    PowerShell AWS Windows PowerShell AWS Amazon EC2 Cmdlet PowerShell AWS Cmdlet Reference

    Amazon EC2 API HTTP HTTPS HTTP GET POST Action Amazon EC2 API Amazon EC2 APIReference Actions

    API HTTP HTTPS AWS AWS SDKsand Tools

    Amazon EC2 AWS AWS Amazon EC2

    Amazon EC2

    Spot

    EC2

    Amazon EC2 Amazon EC2

    3

    http://docs.aws.amazon.com/AmazonRDS/latest/DeveloperGuide/http://docs.aws.amazon.com/vm-import/latest/userguide/http://docs.aws.amazon.com/cli/latest/userguide/http://docs.aws.amazon.com/cli/latest/reference/ec2/index.htmlhttp://docs.aws.amazon.com/powershell/latest/userguide/http://docs.aws.amazon.com/powershell/latest/userguide/http://docs.aws.amazon.com/powershell/latest/reference/Index.htmlhttp://docs.aws.amazon.com/powershell/latest/reference/Index.htmlhttp://docs.aws.amazon.com/AWSEC2/latest/APIReference/query-apis.htmlhttps://aws.amazon.com/tools/https://aws.amazon.com/tools/https://aws.amazon.com/free/https://aws.amazon.com/ec2/pricing

  • Amazon Elastic Compute Cloud Linux PCI DSS

    AWS AWS AWS

    AWS AWS Support

    Trusted Advisor AWS AWS TrustedAdvisor

    PCI DSS Amazon EC2 (PCI) (DSS) PCI DSS AWS PCI Compliance Package PCI DSS 1

    AMIAmazon (AMI) () AMI AMI AMI

    AMI

    AMI Amazon EC2 Amazon EC2

    sudo

    AWS Amazon EC2 Amazon EC2

    4

    https://aws.amazon.com/economics/https://aws.amazon.com/account-activityhttp://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/https://aws.amazon.com/contact-us/https://aws.amazon.com/premiumsupport/trustedadvisor/https://aws.amazon.com/premiumsupport/trustedadvisor/https://aws.amazon.com/compliance/pci-dss-level-1-faqs/https://aws.amazon.com/ec2/instance-types/https://aws.amazon.com/ec2/instance-types/https://aws.amazon.com/ec2/faqs/#How_many_instances_can_I_run_in_Amazon_EC2

  • Amazon Elastic Compute Cloud Linux AMI

    Amazon EC2 (p. 12)

    () (p. 769) Amazon S3 Amazon EBS (p. 658)

    AWS Identity and Access Management (IAM) AWS ()

    AWS IAM AWS Amazon EC2 (p. 483)

    22 SSH Linux Amazon EC2 (p. 470)

    ()

    AMI (p. 86) AMI AMI (p. 81)

    stopped Amazon EBS

    Amazon EBS () Amazon EBS

    Amazon EBS AMIRAM

    Amazon EBS deleteOnTermination

    disableApiTermination true ( Linux shutdown -h Windows shutdown) instanceInitiatedShutdownBehavior stop terminateAmazon EBS stop

    (p. 313)

    AMIAmazon Web Services (AWS) Amazon (AMI) AWS AMI AMI Web

    5

  • Amazon Elastic Compute Cloud Linux

    AMI Web AMI Web

    AMI Amazon EBS AMI Amazon EBS AMI Amazon S3

    AMI (ebs instance store) AMI (p. 77)

    Amazon EC2 Amazon EC2 ()

    Amazon

    (p. 6) (p. 7) (p. 8) (p. 8) (p. 10) (p. 11) (p. 12)

    Amazon EC2 (p. 779)

    Amazon EC2 Amazon EC2

    6

  • Amazon Elastic Compute Cloud Linux

    AMI AMI AMI AMI (p. 127)

    Amazon EC2 -

    IP IP (p. 604)

    us-east-1a us-east-1a us-east-1a

    (p. 8)

    AWS Amazon EC2

    AWS GovCloudAWS GovCloudAWSGovCloud

    Amazon AWS ()

    AWS AWS AWSGovCloud

    us-east-1

    us-east-2

    us-west-1

    us-west-2

    ca-central-1 ()

    eu-central-1

    eu-west-1

    eu-west-2 ()

    7

    https://aws.amazon.com/ec2/pricing/on-demand/#Data_Transferhttps://aws.amazon.com/govcloud-us/https://aws.amazon.com/govcloud-us/

  • Amazon Elastic Compute Cloud Linux

    eu-west-3 ()

    ap-northeast-1

    ap-northeast-2

    ap-northeast-3 ()

    ap-southeast-1

    ap-southeast-2

    ap-south-1

    sa-east-1

    AWS

    AWS Amazon EC2 (p. 8)

    API Amazon EC2 Amazon Web Services

    AWS GovCloudAWS GovCloud (US) UserGuideAWS GovCloud

    Amazon EC2 Amazon EC2 (p. 3)

    1. Amazon EC2 https://console.aws.amazon.com/ec2/2.

    8

    https://aws.amazon.com/about-aws/global-infrastructure/http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_regionhttp://docs.aws.amazon.com/govcloud-us/latest/UserGuide/using-govcloud-endpoints.htmlhttps://console.aws.amazon.com/ec2/

  • Amazon Elastic Compute Cloud Linux

    3. EC2 Dashboard4. Service HealthAvailability Zone Status

    1. [AWS CLI] describe-regions

    aws ec2 describe-regions

    2. [AWS CLI] describe-availability-zones

    aws ec2 describe-availability-zones --region region-name

    3. [ Windows PowerShell AWS ] Get-EC2Region

    PS C:\> Get-EC2Region

    4. [ Windows PowerShell AWS ] Get-EC2AvailabilityZone

    9

    http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-regions.htmlhttp://docs.aws.amazon.com/cli/latest/reference/ec2/describe-availability-zones.htmlhttp://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2Region.htmlhttp://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2AvailabilityZone.html

  • Amazon Elastic Compute Cloud Linux

    PS C:\> Get-EC2AvailabilityZone -Region region-name

    Amazon EC2 AWS

    Note

    AWS

    1. Amazon EC2 https://console.aws.amazon.com/ec2/2.

    10

    https://console.aws.amazon.com/ec2/

  • Amazon Elastic Compute Cloud Linux

    (https://ec2.us-east-2.amazonaws.com)

    AWS_DEFAULT_REGION (AWS CLI) Set-AWSDefaultRegion ( Windows PowerShell AWS )

    --region (AWS CLI) -Region ( Windows PowerShell AWS ) --region us-east-2

    Amazon EC2 Amazon Elastic Compute Cloud

    1. Amazon EC2 https://console.aws.amazon.com/ec2/2. Launch Instance3. Configure Instance Details ()

    [EC2-Classic] No Preference ()

    [EC2-VPC] No Preference (default subnet in anyAvailability Zone) (())

    AWS CLI

    run-instances

    [EC2-Classic] --placement [EC2-VPC] --subnet-id

    Windows PowerShell AWS

    New-EC2Instance

    [EC2-Classic] -AvailabilityZone [EC2-VPC] -SubnetId

    11

    http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_regionhttps://console.aws.amazon.com/ec2/http://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.htmlhttp://docs.aws.amazon.com/powershell/latest/reference/items/New-EC2Instance.html

  • Amazon Elastic Compute Cloud Linux

    AMI

    1. AMI

    Amazon EBS Linux AMI (p. 92) Linux AMI (p. 95) Amazon EBS Windows AMI

    2. [EC2-VPC] IPv4 IPv4 AMI

    3. AMI (p. 11)

    4. IP IP (p. 609)

    5. Reserved Instance() (p. 241)

    6. () (p. 374)

    Amazon EC2 Amazon EC2 AMI Amazon EC2 AMI Amazon S3 Amazon EBS Amazon EBS AMIAMI Amazon EBS Amazon EBS

    Amazon EC2 AMI Amazon EBS AMI Amazon EBS

    Amazon EC2Linux (p. 767)

    (p. 12) AMI (p. 14) (p. 14) (p. 15)

    AMI Amazon EBS AMI AMI AMI ebs( Amazon EBS ) instance store () AMI (p. 77)

    12

    http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/Creating_EBSbacked_WinAMI.html

  • Amazon Elastic Compute Cloud Linux

    (Stop () ) ()

    Amazon Amazon EC2

    Amazon EC2 (p. 752)

    Amazon EBS

    Amazon EBS Amazon EBS Amazon EBS AMI Amazon EBS Amazon EBS Amazon EBS

    Amazon EBS Amazon EBS

    Amazon EBS

    () AMI Amazon EBS Linux

    AMI (p. 92)

    1.

    13

  • Amazon Elastic Compute Cloud Linux AMI

    2. AMI3. AMI 4. Amazon EBS 5. Amazon EBS

    Amazon EBS (p. 660)

    AMI AMI

    Amazon EBS AMI

    1. Amazon EC2 2. AMIs3. ( Public images ()) Platform

    ( Amazon Linux) Root Device Type EBS images4. () Show/Hide Columns (/)

    Close ()5. AMI AMI ID

    AMI

    1. Amazon EC2 2. AMIs3. ( Public images ()) Platform

    ( Amazon Linux) Root Device Type Instance store4. () Show/Hide Columns (/)

    Close ()5. AMI AMI ID

    AMI

    Amazon EC2 (p. 3)

    describe-images (AWS CLI) Get-EC2Image ( Windows PowerShell AWS )

    1. Amazon EC2 2. Instances3.

    ebs Amazon EBS instance store

    14

    http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-images.htmlhttp://docs.aws.amazon.com/powershell/latest/userguide/pstools-ec2-get-amis.html#pstools-ec2-get-image

  • Amazon Elastic Compute Cloud Linux

    Amazon EC2 (p. 3)

    describe-instances (AWS CLI) Get-EC2Instance ( Windows PowerShell AWS )

    Amazon EBS AMI DeleteOnTermination false

    DeleteOnTermination

    1. Amazon EC2 2. Amazon EC2 Launch Instance3. Choose an Amazon Machine Image (AMI) AMI Select4. Choose an Instance Type () Configure Instance Details (

    ) 5. Add Storage () Delete On Termination ()6. Launch

    Block devices () Delete on termination () TrueDelete on termination () False

    AWS CLI AWS CLI DeleteOnTermination

    Example

    run-instances DeleteOnTermination false

    aws ec2 run-instances --block-device-mappings file://mapping.json other parameters...

    mapping.json

    [ { "DeviceName": "/dev/sda1", "Ebs": { "DeleteOnTermination": false } }]

    15

    http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.htmlhttp://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2Instance.htmlhttp://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html

  • Amazon Elastic Compute Cloud Linux

    describe-instances BlockDeviceMappings DeleteOnTermination false

    ... "BlockDeviceMappings": [ { "DeviceName": "/dev/sda1", "Ebs": { "Status": "attached", "DeleteOnTermination": false, "VolumeId": "vol-1234567890abcdef0", "AttachTime": "2013-07-19T02:42:39.000Z" } } ...

    Example

    modify-instance-attribute DeleteOnTermination false

    aws ec2 modify-instance-attribute --instance-id i-1234567890abcdef0 --block-device-mappings file://mapping.json

    mapping.json

    [ { "DeviceName": "/dev/sda1", "Ebs" : { "DeleteOnTermination": false } }]

    16

    http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.htmlhttp://docs.aws.amazon.com/cli/latest/reference/ec2/modify-instance-attribute.html

  • Amazon Elastic Compute Cloud Linux AWS

    Amazon EC2 Amazon Web Services (AWS) Amazon EC2 AmazonEC2 Launch Instance

    AWS Amazon EC2

    1. AWS (p. 17)2. IAM (p. 17)3. (p. 18)4. Virtual Private Cloud (VPC) (p. 21)5. (p. 21)

    AWS Amazon Web Services (AWS) AWS AWS AmazonEC2

    Amazon EC2 AWS Amazon EC2 AWS

    AWS AWS

    AWS

    1. https://aws.amazon.com/ Create an AWS Account

    Note

    AWS Sign in to a different account Create a new AWS account

    2.

    PIN

    AWS

    IAM AWS ( Amazon EC2) AWS API AWS AWS AWS Identity and Access Management (IAM) IAM IAM URL IAM AWS

    AWS IAM IAM AWS

    17

    https://aws.amazon.com/free/https://aws.amazon.com/http://docs.aws.amazon.com/awsconsolehelpdocs/latest/gsg/getting-started.html

  • Amazon Elastic Compute Cloud Linux

    IAM

    1. AWS AWS IAM (https://console.aws.amazon.com/iam/)

    Note

    Administrator IAM

    2. Users Add user3. User name Administrator4. AWS access Custom password

    Require password reset () 5. Next: Permissions6. 7. Create group8. Create group () Group name () Administrators9. Filter policies () AWS managed - job function (AWS - ) 10. AdministratorAccess Create group11. Refresh 12. Next: Review Create

    user

    AWS AWS

    IAM AWS URLyour_aws_account_id AWS ( AWS 1234-5678-9012 AWS ID 123456789012)

    https://your_aws_account_id.signin.aws.amazon.com/console/

    IAM () your_user_name @your_aws_account_id

    URL AWS ID IAM Dashboard Customize URL

    https://your_account_alias.signin.aws.amazon.com/console/

    IAM IAM IAM users sign-in link (IAM )

    IAM IAM Amazon EC2 (p. 484)

    AWS Linux ( SSH )

    18

    http://docs.aws.amazon.com/IAM/latest/UserGuide/id_root-user.htmlhttps://console.aws.amazon.com/iam/https://console.aws.amazon.com/iam/http://docs.aws.amazon.com/general/latest/gr/aws_tasks-that-require-root.htmlhttp://docs.aws.amazon.com/IAM/latest/UserGuide/access.htmlhttp://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_examples.html

  • Amazon Elastic Compute Cloud Linux

    Amazon EC2 (p. 6)

    1. URL AWS2. AWS EC2 Amazon EC2 3.

    4. NETWORK & SECURITY Key Pairs

    Tip

    Key Pairs

    19

  • Amazon Elastic Compute Cloud Linux

    5. Create Key Pair6. Create Key Pair Key pair name Create

    ( IAM ) -key-pair me-key-pair-useast27. .pem

    Important

    8. Mac Linux SSH Linux

    chmod 400 your_user_name-key-pair-region_name.pem

    Amazon EC2 (p. 462)

    Mac Linux Linux -i SSH .pem Windows Linux MindTerm PuTTY PuTTY .pem .ppk

    () PuTTY Windows Linux

    1. http://www.chiark.greenend.org.uk/~sgtatham/putty/ PuTTY2. PuTTYgen ( All Programs > PuTTY > PuTTYgen)3. Type of key to generate RSA

    4. LoadPuTTYgen .ppk .pem

    5. Open OK 6. Save private keyPuTTYgen

    20

    http://www.chiark.greenend.org.uk/~sgtatham/putty/

  • Amazon Elastic Compute Cloud Linux Virtual Private Cloud (VPC)

    7. PuTTY .ppk

    Virtual Private Cloud (VPC)Amazon VPC AWS VPC (p. 21) VPC Amazon EC2 (p. 571) VPC

    Important

    EC2-Classic VPCT2 VPC

    VPC

    1. Amazon VPC https://console.aws.amazon.com/vpc/2. VPC VPC 3. VPC Start VPC Wizard4. Step 1: Select a VPC Configuration VPC with a Single Public Subnet

    Select5. Step 2: VPC with a Single Public Subnet ( 2: VPC) VPC name

    (VPC ) VPC Create VPC OK

    Amazon VPC Amazon VPC ( Amazon VPC )

    SSH IP HTTP HTTPS

    (p. 6)

    IPv4 Amazon EC2 IPv4 Internet what is my IP addressCheck IP Internet (ISP) IP IP

    VPC

    1. Amazon EC2 https://console.aws.amazon.com/ec2/

    Tip

    Amazon VPC AmazonVPC Amazon VPC Amazon EC2 Amazon VPC VPC

    2.

    21

    https://console.aws.amazon.com/vpc/http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/http://checkip.amazonaws.com/https://console.aws.amazon.com/ec2/http://docs.aws.amazon.com/AmazonVPC/latest/GettingStartedGuide/SecurityGroup.htmlhttp://docs.aws.amazon.com/AmazonVPC/latest/GettingStartedGuide/SecurityGroup.html

  • Amazon Elastic Compute Cloud Linux

    3. Security Groups4. Create Security Group5. ( IAM ) _SG_

    me_SG_uswest26. VPC VPC VPC VPC (*)

    Note

    EC2-Classic VPC7. Inbound ( Add Rule) Create

    Type HTTP Source Anywhere (0.0.0.0/0) Type HTTPS Source Anywhere (0.0.0.0/0) Type SSH My IP IPv4

    CIDR IPv4 CIDR IP /32 203.0.113.25/32 203.0.113.0/24

    22

  • Amazon Elastic Compute Cloud Linux

    Warning

    IPv4 (0.0.0.0/0) SSH

    Linux Amazon EC2 (p. 470)

    23

  • Amazon Elastic Compute Cloud Linux

    Amazon EC2 Linux Linux Amazon Elastic Compute Cloud (Amazon EC2) AWS Amazon EC2

    AWS AWS Amazon EC2 12 AWS Amazon EC2 Amazon EC2 ()

    (p. 24) (p. 25) 1 (p. 25) 2 (p. 26) 3 (p. 26) (p. 27)

    Amazon EBS ( EBS ) Amazon EC2

    1. (p. 25)2. (p. 26)3. (p. 26)

    Windows Amazon EC2 Windows Amazon EC2 Windows

    24

    https://aws.amazon.com/free/http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/EC2_GetStarted.html

  • Amazon Elastic Compute Cloud Linux

    AWS Command Line Interface AWS CLI Amazon EC2

    Amazon EC2 (p. 17)

    1 AWS Linux

    1. Amazon EC2 https://console.aws.amazon.com/ec2/2. Launch Instance3. Choose an Amazon Machine Image (AMI) Amazon (AMI)

    HVM Amazon Linux 2 AMI Free tiereligible()

    4. Choose an Instance Type () t2.micro ()

    Note

    T2 ( t2.micro) VPC AWS EC2-Classic VPC VPCReview and Launch Next: Configure Instance Details

    5. Review and Launch 6. Review Instance Launch () Security Groups ()

    a. Edit security groupsb. Configure Security Group Select an existing security group c. Review and Launch

    7. Review Instance Launch Launch8. Choose an existing key pair

    Create a new key pair DownloadKey Pair

    Warning

    Proceed without a key pair ()

    Launch Instances9. View Instances 10.

    pending running DNS ( Public DNS

    25

    http://docs.aws.amazon.com/cli/latest/userguide/cli-using-ec2.htmlhttp://docs.aws.amazon.com/cli/latest/userguide/cli-using-ec2.htmlhttp://docs.aws.amazon.com/AWSEC2/latest/UserGuide/launching-instance.htmlhttps://console.aws.amazon.com/ec2/http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/t2-instances.html

  • Amazon Elastic Compute Cloud Linux 2

    (IPv4) Show/Hide Columns () Public DNS(IPv4))

    11. StatusChecks

    2 Linux PuTTY SSH Amazon Linux2 Linux PuTTY Windows Linux (p. 356) SSH Linux (p. 352)

    Important

    .pem SSH (p. 808)

    Web Linux

    1. Java Java Java Web Java

    2. Amazon EC2 Instances3. Connect4. A Java SSH client directly from my browser (Java required)5. Amazon EC2 DNS Public DNS ( DNS)

    Launch SSH Client

    a. User name () ec2-userb. Private key path (.pem) c. () Store in browser cache

    Amazon EC2 6. Yes Run MindTerm 7. MindTerm

    8.

    No

    Note

    No

    Verification of server key disabled in this session.

    3 (p. 27)

    Important

    26

    http://java.com/en/download/help/index_installing.xmlhttp://java.com/en/download/help/enable_browser.xml

  • Amazon Elastic Compute Cloud Linux

    AWS shutting down terminated

    1. Instances2. ActionsInstance State Terminate3. Yes, Terminate

    Amazon EC2

    Run Command EC2 Amazon EC2 (p. 70) Systems Manager (Run Command)

    CloudWatch AWS Billingand Cost Management

    EBS Amazon EBS (p. 673) Amazon EBS (p. 675)

    LAMP Amazon Linux 2 LAMP Web (p. 29)

    27

    https://aws.amazon.com/free/http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Stop_Start.htmlhttp://docs.aws.amazon.com/systems-manager/latest/userguide/execute-remote-commands.htmlhttp://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/free-tier-alarms.html

  • Amazon Elastic Compute Cloud Linux

    Amazon EC2 Amazon EC2

    IAM IAM AWS API AWS IAM IAM

    (p. 471) Amazon Linux 2 Amazon Linux

    AMI Linux Windows Amazon EC2 Windows Windows

    VPC ( EC2-Classic) 2013-12-04 AWS VPCAmazon EC2 Amazon Virtual PrivateCloud (p. 565)

    (p. 77) Amazon EBS

    Amazon EBS (p. 376)

    AWS (p. 403) Amazon EC2 (p. 787)

    Amazon EC2 AmazonEC2 (p. 795)

    Amazon EBS (p. 713) EBS Amazon (AMI) (p. 75)

    IP Amazon EC2

    IP (p. 590) Amazon EC2 (p. 418) IP

    (p. 612) Amazon EC2 AutoScaling Amazon EC2 Auto Scaling

    Amazon EBS

    28

    http://docs.aws.amazon.com/IAM/latest/UserGuide/IAMBestPractices.htmlhttp://docs.aws.amazon.com/IAM/latest/UserGuide/IAMBestPractices.htmlhttp://docs.aws.amazon.com/AWSEC2/latest/UserGuide/managing-software.htmlhttp://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/windows-ami-version-history.html#update-windows-instancehttp://docs.aws.amazon.com/autoscaling/latest/userguide/

  • Amazon Elastic Compute Cloud Linux LAMP (Amazon Linux 2)

    Linux Amazon EC2

    Linux EC2 AWS

    Amazon Linux 2 LAMP Web (p. 29) Amazon Linux AMI LAMP Web (p. 37) Amazon Linux WordPress (p. 47) Amazon Linux 2 Apache Web SSL/TLS (p. 55) Amazon EC2 (p. 68) Amazon EC2 (p. 70)

    Amazon Linux 2 LAMP Web

    PHP MariaDB ( MySQL ) Apache Web ( LAMP Web LAMP ) Amazon Linux 2 PHP

    Amazon Linux AMI LAMP Web Amazon Linux AMI LAMPWeb (p. 37)

    Important

    Ubuntu Red Hat Enterprise Linux LAMP web Ubuntu LAMP Web Ubuntu ApacheMySQLPHP

    1 LAMP

    Amazon Linux 2 Internet DNS 1 (p. 25) SSH ( 22)HTTP ( 80) HTTPS ( 443) Amazon EC2 (p. 17)

    LAMP

    1. (p. 26)2.

    -y

    [ec2-user ~]$ sudo yum update -y

    29

    https://aws.amazon.com/training/intro_series/https://aws.amazon.com/training/intro_series/https://mariadb.org/about/https://help.ubuntu.com/community/ApacheMySQLPHP

  • Amazon Elastic Compute Cloud Linux 1 LAMP

    3. lamp-mariadb10.2-php7.2 php7.2 Amazon Linux Extras AmazonLinux 2 LAMP MariaDB PHP

    [ec2-user ~]$ sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2

    Note

    sudo: amazon-linux-extras: command not found Amazon Linux 2 AMI Amazon Linux AMI Amazon Linux

    cat /etc/system-release

    Amazon Linux AMI LAMP Web Amazon Linux AMI LAMP Web (p. 37)

    4. Apache Web MariaDB PHP

    yum install

    [ec2-user ~]$ sudo yum install -y httpd mariadb-server

    Note

    yum info package_name

    5. Apache Web

    [ec2-user ~]$ sudo systemctl start httpd

    6. systemctl Apache Web

    [ec2-user ~]$ sudo systemctl enable httpd

    httpd

    [ec2-user ~]$ sudo systemctl is-enabled httpd

    7. HTTP ( 80) launch-wizard-N SSH

    a. Amazon EC2 https://console.aws.amazon.com/ec2/b. Instances c. Security groups view inbound rulesd.

    Security Groups associated with i-1234567890abcdef0Ports Protocol Source launch-wizard-N22 tcp 0.0.0.0/0

    (p. 476)

    TypeHTTP30

    https://console.aws.amazon.com/ec2/

  • Amazon Elastic Compute Cloud Linux 1 LAMP

    ProtocolTCP Port Range80 SourceCustom

    8. Web Web DNS ( IP ) /var/www/html Apache Amazon EC2 DNS ( Public DNS Show/Hide Columns () Public DNS )

    Apache HTTP 80 HTTP (p. 476)

    Important

    Amazon Linux

    Apache httpd Apache Amazon Linux Apache /var/www/html

    ec2-user ec2-user apache /var/www apache

    1. ( ec2-user) apache

    [ec2-user ~]$ sudo usermod -a -G apache ec2-user

    2.

    31

  • Amazon Elastic Compute Cloud Linux 2 LAMP

    a. ( exit )

    [ec2-user ~]$ exit

    b. apache

    [ec2-user ~]$ groupsec2-user adm wheel apache systemd-journal

    3. /var/www apache

    [ec2-user ~]$ sudo chown -R ec2-user:apache /var/www

    4. ID /var/www

    [ec2-user ~]$ sudo chmod 2775 /var/www && find /var/www -type d -exec sudo chmod 2775 {} \;

    5. /var/www

    [ec2-user ~]$ find /var/www -type f -exec sudo chmod 0664 {} \;

    ec2-user ( apache ) Apache PHP

    Web ()

    HTTP Web Web HTTP URL HTML () Web HTTPS (HTTP Secure) SSL/TLS

    HTTPS Amazon Linux Apache Web SSL/TLS

    2 LAMP ec2-user /var/www/html ( Internet ) PHP

    LAMP

    1. Apache PHP

    [ec2-user ~]$ echo "" > /var/www/html/phpinfo.php

    Permission denied () (p. 31)

    2. Web URL URL DNS

    http://my.public.dns.amazonaws.com/phpinfo.php

    PHP

    32

    http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/SSL-on-an-instance.htmlhttp://docs.aws.amazon.com/AWSEC2/latest/UserGuide/SSL-on-an-instance.html

  • Amazon Elastic Compute Cloud Linux 3

    Note

    /var/www/html/phpinfo.php

    [ec2-user ~]$ sudo yum list installed httpd mariadb-server php-mysqlnd

    sudo yum install package amazon-linux-extras php7.2 lamp-mariadb10.2-php7.2Extras

    3. phpinfo.php Internet

    [ec2-user ~]$ rm /var/www/html/phpinfo.php

    LAMP Web Apache ( /var/www/html) DNS

    3MariaDB mysql_secure_installation MariaDB

    MariaDB

    1. MariaDB

    33

  • Amazon Elastic Compute Cloud Linux 4() phpMyAdmin

    [ec2-user ~]$ sudo systemctl start mariadb

    2. mysql_secure_installation

    [ec2-user ~]$ sudo mysql_secure_installation

    a.

    i. Enterii. Y https://

    identitysafe.norton.com/password-generator/

    Note

    MariaDB

    b. Y c. Y d. Y e. Y

    3. () MariaDB

    [ec2-user ~]$ sudo systemctl stop mariadb

    4. () MariaDB

    [ec2-user ~]$ sudo systemctl enable mariadb

    4() phpMyAdminphpMyAdmin Web EC2 MySQL Amazon Linux phpMyAdmin

    Important

    Apache SSL/TLS phpMyAdmin LAMP phpMyAdmin Internet phpMyAdmin EC2 Web Amazon Linux Apache Web SSL/TLS

    phpMyAdmin

    1.

    [ec2-user ~]$ sudo yum install php-mbstring -y

    2. Apache

    [ec2-user ~]$ sudo systemctl restart httpd

    3. php-fpm.

    34

    https://identitysafe.norton.com/password-generator/https://identitysafe.norton.com/password-generator/https://www.phpmyadmin.net/https://docs.phpmyadmin.net/en/latest/setup.html#securing-your-phpmyadmin-installationhttp://docs.aws.amazon.com/AWSEC2/latest/UserGuide/SSL-on-an-instance.html

  • Amazon Elastic Compute Cloud Linux 4() phpMyAdmin

    [ec2-user ~]$ sudo systemctl restart php-fpm

    4. /var/www/html Apache

    [ec2-user ~]$ cd /var/www/html

    5. https://www.phpmyadmin.net/downloads phpMyAdmin wget

    [ec2-user html]$ wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz

    6. phpMyAdmin

    [ec2-user html]$ mkdir phpMyAdmin && tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C phpMyAdmin --strip-components 1

    7. phpMyAdmin-latest-all-languages.tar.gz tarball

    [ec2-user html]$ rm phpMyAdmin-latest-all-languages.tar.gz

    8. () MySQL

    [ec2-user ~]$ sudo systemctl start mariadb

    9. Web phpMyAdmin URL URL DNS ( IP )

    http://my.public.dns.amazonaws.com/phpMyAdmin

    phpMyAdmin

    35

    https://www.phpmyadmin.net/downloads

  • Amazon Elastic Compute Cloud Linux 4() phpMyAdmin

    10. root MySQL phpMyAdmin

    phpMyAdmin

    phpMyAdmin phpMyAdmin

    36

    https://docs.phpmyadmin.net/en/latest/setup.html#manually-creating-the-filehttps://docs.phpmyadmin.net/en/latest/setup.html#using-setup-scripthttps://docs.phpmyadmin.net/en/latest/setup.html#using-setup-scripthttp://docs.phpmyadmin.net/en/latest/user.html

  • Amazon Elastic Compute Cloud Linux

    LAMP

    Web Apache Web

    Web

    httpd

    [ec2-user ~]$ sudo systemctl is-enabled httpd

    httpd LAMP (p. 29)

    Apache HTTP 80 HTTP (p. 476)

    Web WordPress

    WinSCP Linux (p. 361) SCP Linux Linux (p. 354) Amazon Linux WordPress (p. 47)

    Apache Web http://httpd.apache.org/ MariaDB https://mariadb.org/https://mariadb.org/ PHP http://php.net/ chmod https://en.wikipedia.org/wiki/Chmod chown https://en.wikipedia.org/wiki/Chown

    Web Amazon Route53 Amazon Route 53

    Amazon Linux AMI LAMP Web

    PHP MySQL Apache Web ( LAMP Web LAMP ) Amazon Linux PHP

    Amazon Linux 2 LAMP Web Amazon Linux 2 LAMP Web (p. 29)

    37

    http://httpd.apache.org/https://mariadb.org/http://www.mysql.com/http://php.net/https://en.wikipedia.org/wiki/Chmodhttps://en.wikipedia.org/wiki/Chownhttp://docs.aws.amazon.com/Route53/latest/DeveloperGuide/creating-migrating.html

  • Amazon Elastic Compute Cloud Linux LAMP (Amazon Linux AMI)

    Important

    Ubuntu Red Hat Enterprise Linux LAMP web Ubuntu LAMP Web Ubuntu ApacheMySQLPHP

    Amazon Linux AMI Internet DNS 1 (p. 25) SSH ( 22)HTTP ( 80) HTTPS ( 443) Amazon EC2 (p. 17)

    Amazon Linux AMI LAMP Web

    1. (p. 26)2.

    -y

    [ec2-user ~]$ sudo yum update -y

    3. Apache Web MySQL PHP

    Note

    LAMP PHP (p. 46)

    yum install

    [ec2-user ~]$ sudo yum install -y httpd24 php70 mysql56-server php70-mysqlnd

    Note

    No package package-name available AmazonLinux AMI Amazon Linux 2 AmazonLinux

    cat /etc/system-release

    Amazon Linux 2 LAMP Web Amazon Linux 2 LAMP Web (p. 29)

    4. Apache Web

    [ec2-user ~]$ sudo service httpd startStarting httpd: [ OK ]

    5. chkconfig Apache Web

    [ec2-user ~]$ sudo chkconfig httpd on

    chkconfig

    httpd

    38

    https://help.ubuntu.com/community/ApacheMySQLPHP

  • Amazon Elastic Compute Cloud Linux LAMP (Amazon Linux AMI)

    [ec2-user ~]$ chkconfig --list httpdhttpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

    234 5 httpd on ()6. HTTP ( 80)

    launch-wizard-N SSH

    a. Amazon EC2 https://console.aws.amazon.com/ec2/b. Instances c. Security groups view inbound rulesd.

    Security Groups associated with i-1234567890abcdef0Ports Protocol Source launch-wizard-N22 tcp 0.0.0.0/0

    (p. 476)

    TypeHTTP ProtocolTCP Port Range80 SourceCustom

    7. Web Web DNS ( IP ) /var/www/html Apache Amazon EC2 DNS ( Public DNS Show/Hide Columns () Public DNS )

    Apache HTTP 80 HTTP (p. 476)

    Important

    Amazon Linux

    39

    https://console.aws.amazon.com/ec2/

  • Amazon Elastic Compute Cloud Linux LAMP (Amazon Linux AMI)

    Note

    /var/www/html DNS

    Apache httpd Apache Amazon Linux Apache /var/www/html

    [ec2-user ~]$ ls -l /var/wwwtotal 16drwxr-xr-x 2 root root 4096 Jul 12 01:00 cgi-bindrwxr-xr-x 3 root root 4096 Aug 7 00:02 errordrwxr-xr-x 2 root root 4096 Jan 6 2012 htmldrwxr-xr-x 3 root root 4096 Aug 7 00:02 iconsdrwxr-xr-x 2 root root 4096 Aug 7 21:17 noindex

    ec2-user ec2-user apache /var/www apache

    40

  • Amazon Elastic Compute Cloud Linux LAMP (Amazon Linux AMI)

    1. ( ec2-user) apache

    [ec2-user ~]$ sudo usermod -a -G apache ec2-user

    2.

    a. ( exit )

    [ec2-user ~]$ exit

    b. apache

    [ec2-user ~]$ groupsec2-user wheel apache

    3. /var/www apache

    [ec2-user ~]$ sudo chown -R ec2-user:apache /var/www

    4. ID /var/www

    [ec2-user ~]$ sudo chmod 2775 /var/www[ec2-user ~]$ find /var/www -type d -exec sudo chmod 2775 {} \;

    5. /var/www

    [ec2-user ~]$ find /var/www -type f -exec sudo chmod 0664 {} \;

    ec2-user ( apache ) Apache PHP

    () Web

    HTTP Web Web HTTP URL HTML () Web HTTPS (HTTP Secure) SSL/TLS

    HTTPS Amazon Linux Apache Web SSL/TLS

    LAMP Web

    ec2-user /var/www/html ( Internet ) PHP

    1. Apache PHP

    [ec2-user ~]$ echo "" > /var/www/html/phpinfo.php

    Permission denied () (p. 41)

    2. Web URL URL DNS

    41

    http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/SSL-on-an-instance.htmlhttp://docs.aws.amazon.com/AWSEC2/latest/UserGuide/SSL-on-an-instance.html

  • Amazon Elastic Compute Cloud Linux LAMP (Amazon Linux AMI)

    http://my.public.dns.amazonaws.com/phpinfo.php

    PHP

    /var/www/html/phpinfo.php

    [ec2-user ~]$ sudo yum list installed httpd24 php70 mysql56-server php70-mysqlndLoaded plugins: priorities, update-motd, upgrade-helperInstalled Packageshttpd24.x86_64 2.4.25-1.68.amzn1 @amzn-updatesmysql56-server.x86_64 5.6.35-1.23.amzn1 @amzn-updatesphp70.x86_64 7.0.14-1.20.amzn1 @amzn-updatesphp70-mysqlnd.x86_64 7.0.14-1.20.amzn1 @amzn-updates

    sudo yum install package 3. phpinfo.php Internet

    [ec2-user ~]$ rm /var/www/html/phpinfo.php

    MySQL mysql_secure_installation MySQL

    42

  • Amazon Elastic Compute Cloud Linux LAMP (Amazon Linux AMI)

    1. MySQL

    [ec2-user ~]$ sudo service mysqld startInitializing MySQL database: ...

    PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !...

    Starting mysqld: [ OK ]

    2. mysql_secure_installation

    [ec2-user ~]$ sudo mysql_secure_installation

    a.

    i. Enterii. Y https://

    identitysafe.norton.com/password-generator/Note

    MySQL

    b. Y c. Y d. Y e. Y

    3. () MySQL

    [ec2-user ~]$ sudo service mysqld stopStopping mysqld: [ OK ]

    4. () MySQL

    [ec2-user ~]$ sudo chkconfig mysqld on

    LAMP Web Apache ( /var/www/html) DNS

    () phpMyAdmin

    phpMyAdmin Web EC2 MySQL Amazon Linux phpMyAdmin

    Important

    Apache SSL/TLS phpMyAdmin LAMP phpMyAdmin Internet phpMyAdmin EC2 Web Amazon Linux Apache Web SSL/TLSNote

    Amazon Linux PHP 7 phpMyAdmin phpMyAdmin

    43

    https://identitysafe.norton.com/password-generator/https://identitysafe.norton.com/password-generator/https://www.phpmyadmin.net/https://docs.phpmyadmin.net/en/latest/setup.html#securing-your-phpmyadmin-installationhttp://docs.aws.amazon.com/AWSEC2/latest/UserGuide/SSL-on-an-instance.html

  • Amazon Elastic Compute Cloud Linux LAMP (Amazon Linux AMI)

    1. SSH EC2 2.

    [ec2-user ~]$ sudo yum install php70-mbstring.x86_64 php70-zip.x86_64 -y

    3. Apache

    [ec2-user ~]$ sudo service httpd restartStopping httpd: [ OK ]Starting httpd: [ OK ]

    4. /var/www/html Apache

    [ec2-user ~]$ cd /var/www/html[ec2-user html]$

    5. https://www.phpmyadmin.net/downloads phpMyAdmin wget

    [ec2-user html]$ wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz

    6. phpMyAdmin

    [ec2-user html]$ mkdir phpMyAdmin && tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C phpMyAdmin --strip-components 1

    7. phpMyAdmin-latest-all-languages.tar.gz tarball

    [ec2-user html]$ rm phpMyAdmin-latest-all-languages.tar.gz

    8. () MySQL

    [ec2-user ~]$ sudo service mysqld startStarting mysqld: [ OK ]

    9. Web phpMyAdmin URL URL DNS ( IP )

    http://my.public.dns.amazonaws.com/phpMyAdmin

    phpMyAdmin

    44

    https://www.phpmyadmin.net/downloads

  • Amazon Elastic Compute Cloud Linux LAMP (Amazon Linux AMI)

    10. root MySQL phpMyAdmin

    phpMyAdmin

    phpMyAdmin phpMyAdmin

    45

    https://docs.phpmyadmin.net/en/latest/setup.html#manually-creating-the-filehttps://docs.phpmyadmin.net/en/latest/setup.html#using-setup-scripthttps://docs.phpmyadmin.net/en/latest/setup.html#using-setup-scripthttp://docs.phpmyadmin.net/en/latest/user.html

  • Amazon Elastic Compute Cloud Linux

    LAMP

    Web Apache Web

    Web

    httpd

    [ec2-user ~]$ chkconfig --list httpdhttpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

    234 5 httpd on ()

    httpd Amazon Linux AMI LAMP Web (p. 38)

    Apache HTTP 80 HTTP (p. 476)

    PHP Apache HTTP ServerPHP MySQL LAMP PHP () PHP PHP Amazon Linux AMI 2016.09

    LAMP

    httpd24 php56 mysql55-server php56-mysqlnd

    [ec2-user ~]$ sudo yum remove -y httpd24 php70 mysql56-server php70-mysqlnd perl-DBD-MySQL56

    [ec2-user ~]$ sudo yum install -y httpd24 php56 mysql55-server php56-mysqlnd

    46

    https://aws.amazon.com/amazon-linux-ami/2016.09-release-notes/

  • Amazon Elastic Compute Cloud Linux

    [ec2-user ~]$ sudo yum remove -y httpd24 php56 mysql55-server php56-mysqlnd perl-DBD-MySQL55

    Web WordPress

    WinSCP Linux (p. 361) SCP Linux Linux (p. 354) Amazon Linux WordPress (p. 47)

    Apache Web http://httpd.apache.org/ MySQL http://www.mysql.com/ PHP http://php.net/ chmod https://en.wikipedia.org/wiki/Chmod chown https://en.wikipedia.org/wiki/Chown

    Web Amazon Route53 Amazon Route 53

    Amazon Linux WordPress Amazon Linux WordPress AmazonEC2 WordPress Web

    Web WordPress AWS CloudFormation WordPress AWS CloudFormation WordPress Windows Amazon EC2 Windows Amazon EC2Windows WordPress AWSElastic Beanstalk WordPress

    Important

    Amazon Linux Ubuntu Ubuntu WordPress Ubuntu WordPress

    Amazon Linux AMI LAMP Web (p. 37) ( Amazon Linux AMI) Amazon Linux 2 LAMP Web (p. 29) ( Amazon Linux 2) Amazon Linux PHP (MySQL MariaDB) Web HTTP HTTPS Web (p. 476)

    47

    http://httpd.apache.org/http://www.mysql.com/http://php.net/https://en.wikipedia.org/wiki/Chmodhttps://en.wikipedia.org/wiki/Chownhttp://docs.aws.amazon.com/Route53/latest/DeveloperGuide/creating-migrating.htmlhttp://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/GettingStarted.Walkthrough.htmlhttp://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/EC2Win_CreateWordPressBlog.htmlhttp://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/EC2Win_CreateWordPressBlog.htmlhttp://docs.aws.amazon.com/elasticbeanstalk/latest/dg/php-hawordpress-tutorial.htmlhttps://help.ubuntu.com/community/WordPress

  • Amazon Elastic Compute Cloud Linux WordPress

    IP (EIP) WordPress DNS DNS EIP () EIP IP (p. 604)

    Route53 EIP Amazon Route53 Amazon Route 53

    WordPress WordPress

    WordPress

    1. wget WordPress

    [ec2-user ~]$ wget https://wordpress.org/latest.tar.gz

    2. wordpress

    [ec2-user ~]$ tar -xzf latest.tar.gz

    WordPress

    WordPress

    1.

    Amazon Linux AMIsudo service mysql