amazon elastic compute cloud elastic compute cloud linux インスタンス用ユーザーガイド...

956
Amazon Elastic Compute Cloud Linux インスタンス用ユーザーガイド

Upload: hadan

Post on 08-Mar-2018

396 views

Category:

Documents


27 download

TRANSCRIPT

  • Amazon Elastic Compute CloudLinux

  • Amazon Elastic Compute CloudLinux

    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 CloudLinux

    Table of ContentsAmazon EC2 .............................................................................................................................. 1

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

    ..................................................................................................................... 5AMI .................................................................................................................................. 6

    ......................................................................................... 7 .............................................................. 7 ......................................................................................................... 8 ................................................................................................ 9 ....................................................................... 9 .............................................................................................. 11 ................................................................ 12 ............................................................ 13

    ......................................................................................................... 14 ........................................................................................ 14 AMI ............................................................................. 16 ......................................................................... 17 ............................................................................ 17

    .................................................................................................................................... 19AWS .......................................................................................................... 19IAM ............................................................................................................ 19 ......................................................................................................................... 21Virtual Private Cloud (VPC) .............................................................................................. 24 ...................................................................................................... 24

    ....................................................................................................................... 27 ........................................................................................................................................ 27 .................................................................................................................................. 28 1: ........................................................................................... 28 2: ................................................................................................. 29 3: ............................................................................ 30 ............................................................................................................................ 30

    .......................................................................................................................... 32 ................................................................................................................................. 34

    LAMP (Amazon Linux 2) ................................................................... 34 1: LAMP ................................................................................ 34 2: LAMP ............................................................................. 38 3: .................................................. 39 4: () phpMyAdmin .................................................... 40 .................................................................................................... 43 .................................................................................................................... 43

    LAMP (Amazon Linux AMI) ............................................................... 44 .................................................................................................... 43 .................................................................................................................... 43

    : WordPress ........................................................................ 53 .......................................................................................................................... 54WordPress ................................................................................................ 54 .................................................................................................................... 60! DNS ......................................... 61

    : Amazon Linux 2 SSL/TLS Apache ... 62

    iii

  • Amazon Elastic Compute CloudLinux

    .......................................................................................................................... 63 1: SSL/TLS ........................................................................ 63 2: CA ....................................................................................... 65 3: ....................................................................... 70 .................................................................................................... 72: Amazon Linux 2 Let's Encrypt Certbot .................................................... 73

    : ......................................................................... 77 .......................................................................................................................... 78 ......................................................................... 78 ........................................................................................... 80

    : ...................................................................... 80 Systems Manager .............................................. 81SSM ...................................................................................... 81EC2 ..................................................................... 81AWS Tools for Windows PowerShell ........................................ 82AWS CLI ............................................................................. 83 .......................................................................................................................... 84

    Amazon .................................................................................................................... 85AMI .............................................................................................................................. 85 AMI .................................................................................................................... 85AMI ............................................................................................................ 86AMI ........................................................................................................................ 86Amazon Linux AMI .................................................................................................................... 86AMI .............................................................................................................................. 86

    .......................................................................................................................... 87 .............................................................................................. 87

    ............................................................................................................................ 89Linux AMI ...................................................................................................................... 90

    Amazon EC2 Linux AMI ........................................................... 91AWS CLI AMI ........................................................................................ 92

    AMI ................................................................................................................................. 92 AMI ......................................................................................................... 92AMI .......................................................................................................... 94 AWS AMI .......................................................................... 96 .......................................................................................................... 97 Linux AMI .......................................................................................... 97

    AMI ................................................................................................................................ 101 AMI ................................................................................................. 102 AMI ....................................................................................................... 102 AMI ............................................................................................................. 103 ................................................................................ 103 ......................................................................................................... 104 AMI ............................................................................ 104AWS Marketplace ...................................................................... 104

    Amazon EBS-Backed Linux AMI ..................................................................................... 105Amazon EBS-backed AMI ............................................................................. 105 Linux AMI ............................................................................... 106 Linux AMI ......................................................................... 108

    Instance Store-Backed Linux AMI .................................................................................... 109Instance Store-Backed AMI ............................................................... 109 ........................................................................................................................ 109AMI ..................................................................................................... 110Instance Store-Backed AMI ..................................................... 113Amazon EBS-Backed AMI ................................................................................... 120AMI .................................................................................................. 123

    AMI .................................................................................. 140 EBS AMI ................................................. 141

    iv

  • Amazon Elastic Compute CloudLinux

    AMI ......................................................................................................................... 143Instance Store-Backed AMI ......................................................... 144 AMI ........................................................................................ 144 AMI ........................................................................................ 145 AMI .................................................................................................... 146AMI ................................................................................................................. 147 AMI .................................................................................. 148

    Linux AMI .............................................................................................................. 149Amazon EBS-Backed AMI ................................................................ 149Instance Store-Backed AMI ............................................................... 150

    Amazon Linux ......................................................................................................................... 151Amazon Linux ................................................................................. 151Amazon Linux .......................................................................................... 152 AWS .................................................................... 153 ...................................................................................................... 154Extras Library (Amazon Linux 2) ....................................................................................... 155 ....................................................................... 156cloud-init ........................................................................................................................ 156Amazon Linux ........................................................................... 158Amazon Linux 2 ................................................ 159

    .............................................................................................................. 160HVM AMI (GRUB) ........................................................................................................... 160AMI (PV-GRUB) ............................................................................................. 161

    .................................................................................................................................. 167 ................................................................................................................. 167

    ......................................................................................... 168 ............................................................................................................ 169 .................................................................................................................. 170 ............................................................................. 170 ......................................................................................................... 171T2 ............................................................................................................. 172 ............................................................................................................ 194 ...................................................................................... 197 ................................................................................................ 200 ......................................................................................... 204 ................................................................................ 209T1 ................................................................................................. 219 ................................................................................................ 230

    ..................................................................................................... 234 ................................................................................ 235 ................................................................................................... 235 ...................................................................................... 271 ...................................................................................................... 275Dedicated Host ............................................................................................................... 328 ......................................................................................... 341

    ................................................................................................. 346 ......................................................................................................... 346 (Amazon EBS-Backed ) ..................................... 347 ...................................................................................................... 347 ................................................................................................... 347 ......................................................................................................... 348 ................................................................................................ 348 ........................................................................................................................ 349 .............................................................................................................................. 370 ..................................................................................................................... 384 ........................................................................................................................... 387 ........................................................................................................................ 387

    v

  • Amazon Elastic Compute CloudLinux

    .............................................................................................................................. 390 .............................................................................................................................. 395

    ................................................................................................................. 396 ...................................................................................................... 396 ......................................................................................................... 397 ............................................................................................................... 405 ................................................................................................ 406 ..................................................................................................................... 411 ............................................................................................................... 415 DNS ............................................................................................. 418 ................................................................................................... 419 .......................................................................... 425

    ................................................................................................................. 440 UUID ..................................................................................................... 440 .............................................................. 441

    .................................................................................................................................. 442 ........................................................................................ 443

    ................................................................................................... 443 ................................................................................................... 444

    ........................................................................................... 444 .................................................................................. 445

    ............................................................................................. 445 ................................................................................................... 450

    CloudWatch ................................................................... 454 ................................................................................................ 454 ................................................................................... 456 ...................................................................................... 464 ...................................................................................................... 472 ............................................................................................................... 472 ............................... 473

    CloudWatch Amazon EC2 ................................................................... 482 ............................................................................ 482

    CloudWatch ....................................................................... 482CloudWatch ................................................................................. 483

    ............................................................................................................. 492 ................................................................................................................................ 492

    Amazon EC2 ...................................................................... 494 Amazon EC2 ...................................................... 494 (Linux) ...................................................................... 496 (Windows) ................................................................. 496 ........................................................ 496 ................................................................................ 497 ............................................................................................................... 497 .......................................................................... 498 Linux ........................................... 499

    .............................................................................................................. 502EC2-Classic ................................................................................. 503EC2-VPC .................................................................................... 503 ......................................................................................... 503 ................................................................................... 506 ...................................................................................... 507 ...................................................................................... 507 .................................................................... 512

    ....................................................................................................................... 518 ............................................................................. 519Amazon EC2 ..................................................................................... 519IAM Amazon EC2 ....................................................................................................... 519

    vi

  • Amazon Elastic Compute CloudLinux

    IAM ................................................................................................................. 521IAM ..................................................................................................................... 593 ...................................................................................................... 601

    Amazon VPC .......................................................................................................................... 604VPC ....................................................................................................... 604EC2-Classic EC2-VPC ....................................................................................... 605EC2-Classic EC2-VPC ............................................ 608VPC ......................................................................... 609Amazon VPC .............................................................................................. 610 ................................................................................ 610ClassicLink ..................................................................................................................... 611EC2-Classic VPC ....................................................................................... 622

    IP ............................................................................................ 633 IPv4 DNS ............................................................... 633 IPv4 DNS .................................................................. 634Elastic IP (IPv4) ................................................................................................. 635Amazon DNS .................................................................................................... 635IPv6 ................................................................................................................. 635EC2-Classic EC2-VPC IP .................................................................. 636 IP .................................................................................... 637 IP .......................................................................................................... 641

    Elastic IP .................................................................................................................. 650Elastic IP ................................................................................................. 650EC2-Classic EC2-VPC Elastic IP ...................................................... 651Elastic IP ................................................................................................. 653 DNS ........................................................... 658Elastic IP ................................................................................................. 658

    ................................................................................................. 659 ................................................................................ 659 IP ....................... 660 .......................................................................... 665 ........................................ 667 ............................................................................. 668 ..................................................... 677

    ........................................................................................................... 678 ...................................................................................... 679 ................................................................................... 679 ............................................................................. 680 ......................................................................................... 681 ................................................................. 681 .................................................................... 682 ................................................................................... 683

    MTU .................................................................................................................. 683 (9001 MTU) .......................................................................................... 684 MTU ............................................................................................................... 6842 MTU ....................................................................................... 685Linux MTU .................................................................. 685 ................................................................................................... 686

    .............................................................................................................. 686 ......................................................................................... 686 ................................................................. 687: Intel 82599 VF ................................................................... 687: ENA ................................................................................. 696ENA ........................................................................................ 706

    ..................................................................................................................................... 713Amazon EBS .......................................................................................................................... 714

    Amazon EBS ....................................................................................................... 715

    vii

  • Amazon Elastic Compute CloudLinux

    EBS .............................................................................................................. 716EBS ................................................................................................... 778EBS .................................................................................................................... 789EBS .................................................................................................................... 794EBS NVMe ................................................................................................. 798EBS ........................................................................................................ 800EBS CloudWatch ............................................................................................... 818

    ................................................................................................................. 826 ......................................................................................... 826 ......................................................................................... 827 .......................................................................... 830SSD .................................................................................. 833 ............................................................................. 834 ...................................................................................... 836

    Amazon EFS .......................................................................................................................... 837 ........................................................................................................................ 838 1: EFS ........................................................................... 8382: ................................................................ 8383: .......................................................................... 840 4: .................................................................................................... 840

    Amazon S3 ............................................................................................................................ 841Amazon S3 Amazon EC2 ............................................................................................. 841

    .............................................................................................. 842Linux .......................................................................................... 843Windows ..................................................................................... 843 ................................................................................................ 843 .................................................................................................................. 843

    ................................................................................................................. 844 ...................................................................................................... 844 ............................................................................................. 845

    ..................................................................................................... 845 ................................................................................... 846AMI ...................................................................................... 848 .......................................................................... 851

    ................................................................................................. 854 ......................................................................................... 854 ......................................................................................... 855 ..................................... 855 ........................................... 856

    ............................................................................................................................... 857 ....................................................................................................................... 857 ID ............................................................................................................................ 858

    ID ................................................................................................................ 859 ID ................................................................................. 862

    ..................................................................................... 863 ..................................................................................................................... 863 ................................................................. 864 ........................................................... 865CLI API .......................................................... 866

    ........................................................................................................... 867 ..................................................................................................................... 867 ................................................................................................... 868 ..................................................................................................................... 870 ...................................................................................... 871 ................................................................................................ 871CLI API ......................................................................................... 874

    .......................................................................................................................... 876

    viii

  • Amazon Elastic Compute CloudLinux

    ......................................................................................................... 876 ............................................................................................. 877

    .................................................................................................................... 878Linux EC2Rescue ....................................................................................................................... 879

    Linux EC2Rescue ......................................................................................... 879Linux EC2Rescue ............................................................................................... 880

    .................................................................................................................. 880 ...................................................................................................... 881 ................................................................................................... 881 ......................................................................................................... 881

    EC2Rescue ............................................................................................ 882 ............................................................................................. 882 ......................................................................................................... 884YAML ..................................................................................................... 885 ............................................................................................................... 886

    ................................................................................................................... 887 ................................................................................................................. 887

    ......................................................................................... 887 .............................................................................................................. 888

    : .................................................................. 888: ......................................................... 890: Host key not foundPermission denied (publickey) Authentication failed,permission denied ( (publickey)) ....................................................................................................................... 892: Unprotected Private Key File () .................. 893: Server refused our key No supported authentication methods available () ........................ 894Safari MindTerm ....................................................................... 894macOS RDP .......................................................................... 895 Ping ........................................................................ 895

    ................................................................................................................. 895 ............................................................................................. 895

    ................................................................................................................. 897 ................................................................................................ 897 ............................................................................. 897 ....................................................................... 897

    ........................................................................................................ 898 ..................................................................................................... 898

    ..................................................................................................................... 899 ......................................................................................................... 899Linux ................. 900: .............................................................................................. 901: mmu_update failed () .............................................. 901I/O () .................................................................................... 902I/O : () ...... 903request_module: runaway loop modprobe ( Linux modprobe) ........................................................................................................... 904FATAL: kernel too oldfsck: No such file or directory while trying to open /dev( AMI ) ............................................................................................... 905FATAL: Could not load /lib/modulesBusyBox () ........... 905: (EC2 ) ........................................................ 907request_module: runaway loop modprobe ( Linux modprobe) ........................................................................................................... 908fsck: No such file or directory while trying to open... () .............. 909General error mounting filesystems () ............................................................... 910VFS: Unable to mount root fs on unknown-block () ..................... 912

    ix

  • Amazon Elastic Compute CloudLinux

    : Unable to determine major/minor number of root device... (/) .................................................................................................................... 913XENBUS: Device with no driver... ...................................................................................... 914... days without being checked, check forced () .............. 915fsck died with exit status... () ........................................................ 915GRUB (grubdom>) .......................................................................................... 916Bringing up interface eth0: Device eth0 has different MAC address than expected, ignoring. ( MAC ) ......................................................................................... 918SELinux Machine is in enforcing mode. Halting now. (SELinux ) ............................................................................................................................. 919XENBUS: Timeout connecting to devices (Xenbus ) ........................................... 920

    ................................................................................................................. 921: InsufficientInstanceCapacity ................................................................................... 921: InstanceLimitExceeded .......................................................................................... 921

    ............................................................................ 922 ...................................................................................................... 922 ............................................................................................. 922 ........................................................ 923 ........................................... 923

    ................................................................................................. 924 ............................................................................................................................ 926AWS ................................................................................................................................ 946

    x

  • Amazon Elastic Compute CloudLinux

    Amazon EC2

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

    Amazon EC2 Amazon EC2

    (

    )Amazon Machine Image (AMI) CPU

    (AWS

    )

    Amazon EBS Amazon Elastic Block Store (Amazon EBS)

    Amazon EBS

    IP

    Elastic IP IPv4 Amazon EC2 AWS

    (VPC)

    Amazon EC2 Amazon EC2

    AWS

    Amazon EC2 Amazon EC2 Amazon EC2 Amazon EC2

    Amazon EC2 (p. 19)

    1

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

  • Amazon Elastic Compute CloudLinux

    Amazon EC2 Linux (p. 27)

    AMI (p. 4) (p. 7) (p. 167) (p. 867)

    Amazon EC2 (p. 492) (p. 502) Elastic IP (p. 650) Amazon EC2 Amazon VPC (p. 604)

    Amazon EBS (p. 714) (p. 826)

    Linux

    Remote Management (Run Command) : Amazon Linux AMI LAMP (p. 44) : Amazon Linux 2 SSL/TLS Apache

    (p. 62) AWS : Linux

    AWS AWS AmazonEC2 Amazon EC2 forum

    Amazon EC2 Amazon EC2 AWS Amazon EC2

    Amazon EC2 Auto Scaling AWS CloudFormation AWS Elastic Beanstalk AWS OpsWorks

    Elastic LoadBalancing Elastic Load Balancing

    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/

  • Amazon Elastic Compute CloudLinux

    Amazon EC2

    Amazon EBS AmazonCloudWatch Amazon CloudWatch

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

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

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

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

    Amazon EC2 Amazon EC2 Amazon EC2 AWS AWS [EC2] Amazon EC2

    AWS (CLI)

    AWS WindowsMac Linux AWS Command Line Interface Amazon EC2 AWS CLI Command Referenceec2

    AWS Tools for Windows PowerShell

    PowerShell AWS AWS Tools for Windows PowerShell Amazon EC2 AWS Tools for PowerShell CmdletReference

    Amazon EC2 API HTTP (GET POST) Action HTTP HTTPS Amazon EC2 API Amazon EC2 API ReferenceActions

    HTTP HTTPS API AWS AWS SDK

    3

    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/http://docs.aws.amazon.com/AmazonRDS/latest/DeveloperGuide/http://docs.aws.amazon.com/vm-import/latest/userguide/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/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/

  • Amazon Elastic Compute CloudLinux

    Amazon EC2

    Amazon EC2 AWS AWS Amazon EC2

    Amazon EC2

    1 3

    EC2

    Amazon EC2 Amazon EC2

    AWS AWS AWS Account Billing

    AWS AWS

    AWS TrustedAdvisor AWS Trusted Advisor

    PCI DSS Amazon EC2 Payment Card Industry (PCI) Data Security Standard (DSS) PCI DSS (AWS PCI Compliance Package ) PCI DSS 1

    AMIAmazon (AMI) () AMI AMI 1 AMI

    4

    https://aws.amazon.com/free/https://aws.amazon.com/ec2/pricinghttps://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/contact-us/https://aws.amazon.com/premiumsupport/trustedadvisor/https://aws.amazon.com/compliance/pci-dss-level-1-faqs/

  • Amazon Elastic Compute CloudLinux

    AMI

    1 AMI Amazon EC2 Amazon EC2

    sudo

    AWS Amazon EC2 Amazon EC2

    Amazon EC2 (p. 14)

    (p. 845) AmazonS3 Amazon EBS (p. 713)

    AWS Identity and Access Management (IAM) AWS

    AWS IAM AWS

    5

    https://aws.amazon.com/ec2/instance-types/https://aws.amazon.com/ec2/faqs/#How_many_instances_can_I_run_in_Amazon_EC2https://aws.amazon.com/ec2/faqs/#How_many_instances_can_I_run_in_Amazon_EC2

  • Amazon Elastic Compute CloudLinux

    AMI

    Amazon EC2 (p. 518)

    22 SSH Linux Amazon EC2 (p. 502)

    AMI (p. 98)AMI AMI (p. 92)

    stopped Amazon EBS

    1 Amazon EBS Amazon EBS

    Amazon EBS AMI RAM

    Amazon EBS ( deleteOnTermination )

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

    (p. 346)

    AMI (AWS) Amazon Machine Image (AMI) AWS AMI AMI

    6

  • Amazon Elastic Compute CloudLinux

    AMI AMI

    AMI Amazon EBS-backed (AMI Amazon EBS ) Instance-store backed (AMI Amazon S3 )

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

    Amazon EC2 1 Amazon EC2

    Amazon 1

    (p. 7) (p. 8) (p. 9) (p. 9) (p. 11) (p. 12) (p. 13)

    7

  • Amazon Elastic Compute CloudLinux

    Amazon EC2 (p. 857)

    Amazon EC2 Amazon EC2

    AMI AMI AMI AMI (p. 143)

    Amazon EC2Pricing - Data Transfer

    1

    Elastic IP Elastic IP (p. 650)

    (us-east-1a ) us-east-1a us-east-1a

    (p. 9)

    (:

    AWS AmazonEC2

    AWS GovCloud () AWS GovCloud () AWS GovCloud ()

    Amazon AWS () ()

    8

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

  • Amazon Elastic Compute CloudLinux

    AWS AWS (AWS GovCloud () () )

    us-east-1

    us-east-2 ()

    us-west-1 ()

    us-west-2 ()

    ca-central-1 ()

    eu-central-1 ()

    eu-west-1 ()

    eu-west-2 ()

    eu-west-3 EU ()

    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. 9)

    API Amazon EC2 ( )

    AWS GovCloud () AWS GovCloud () (AWS GovCloud (US) User Guide)

    Amazon EC2 Amazon EC2 (p. 3)

    9

    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.htmlhttp://docs.aws.amazon.com/govcloud-us/latest/UserGuide/using-govcloud-endpoints.html

  • Amazon Elastic Compute CloudLinux

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

    3. [EC2 ] 4. [] []

    1. [AWS CLI] describe-regions

    aws ec2 describe-regions

    2. [AWS CLI] describe-availability-zones

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

    10

    https://console.aws.amazon.com/ec2/http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-regions.htmlhttp://docs.aws.amazon.com/cli/latest/reference/ec2/describe-availability-zones.html

  • Amazon Elastic Compute CloudLinux

    3. [AWS Tools for Windows PowerShell] Get-EC2Region

    PS C:\> Get-EC2Region

    4. [AWS Tools for Windows PowerShell] Get-EC2AvailabilityZone

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

    Amazon EC2 AWS

    Note

    AWS

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

    11

    http://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2Region.htmlhttp://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2AvailabilityZone.htmlhttps://console.aws.amazon.com/ec2/

  • Amazon Elastic Compute CloudLinux

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

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

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

    Amazon EC2 Amazon Elastic Compute Cloud Endpoints

    1

    12

    http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region

  • Amazon Elastic Compute CloudLinux

    1. https://console.aws.amazon.com/ec2/) Amazon EC2 2. [Launch Instance] 3. [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

    AWS Tools for Windows PowerShell

    New-EC2Instance

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

    1

    AMI

    1. AMI

    13

    https://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 CloudLinux

    Amazon EBS-Backed Linux AMI (p. 105) Instance Store-Backed Linux AMI (p. 109) Amazon EBS-backed Windows AMI

    2. [EC2-VPC] IPv4 IPv4 AMI

    3. AMI (p. 12)

    4. Elastic IP Elastic IP (p. 655)

    5. () (p. 265)

    6. () (p. 391)

    Amazon EC2 Amazon EC2 AMI Amazon EC2 backedAMI AmazonS3 Amazon EBS Amazon EBS AMI AMI Amazon EBS Amazon EBS

    Amazon EC2 backed AMI Amazon EBS backed AMI Amazon EBS backed AMI

    Amazon EC2 Linux (p. 844)

    (p. 14) AMI (p. 16) (p. 17) (p. 17)

    instance store-backed AMI Amazon EBS-backed AMI AMI ebs (Amazon EBS-

    14

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

  • Amazon Elastic Compute CloudLinux

    Backed ) instance store (Instance store-Backed ) AMI (p. 87)

    instance store-backed

    1

    (Instance store-Backed [Stop] ) ()

    instance store-backed Amazon EC2instance store-backed

    Amazon EC2 (p. 826)

    Amazon EBS-backed

    Amazon EBS Amazon EBS Amazon EBS Backed AMI Amazon EBS 1 Amazon EBS Amazon EBS

    Amazon EBS-backed Amazon EBS-backed

    15

  • Amazon Elastic Compute CloudLinux

    AMI

    Amazon EBS-backed

    () AMI

    Amazon EBS-Backed Linux AMI (p. 105)

    1. 2. AMI 3. AMI 4. Amazon EBS 5. Amazon EBS

    Amazon EBS (p. 716)

    AMI AMI

    Amazon EBS-Backed AMI

    1. Amazon EC2 2. [AMIs] 3. ([Public images] ) [Platform]

    ([Amazon Linux] ) [Root Device Type] [EBS images]

    4. () [Show/Hide Columns] [Close]

    5. AMI AMI ID

    instance store-backed AMI

    1. Amazon EC2 2. [AMIs] 3. ([Public images] ) [

  • Amazon Elastic Compute CloudLinux

    1. Amazon EC2 2. [Instances] 3. [Description] [Root device type]

    ebs Amazon EBS-Backed instance store Instance store-Backed

    1 Amazon EC2 (p. 3)

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

    Amazon EBS-backed AMI DeleteOnTermination false

    DeleteOnTermination

    1. Amazon EC2 2. Amazon EC2 [Launch Instance] 3. [Choose an Amazon Machine Image (AMI)] AMI [Select]

    4. [Choose an Instance Type] [Configure Instance Details]

    5. [Add Storage] [Delete On Termination] 6. [Launch ]

    [Block devices] [Delete on termination] [True] [Delete on termination] [False]

    AWS CLI AWS CLI DeleteOnTermination

    17

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

  • Amazon Elastic Compute CloudLinux

    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 } }]

    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 } }]

    18

    http://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.htmlhttp://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 CloudLinux

    AWS

    Amazon EC2 (AWS) Amazon EC2 Amazon EC2 [Launch Instance]

    AWS Amazon EC2

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

    AWS (AWS) AWS AWS (Amazon EC2 )

    Amazon EC2 AWS Amazon EC2 AWS Free Tier

    AWS AWS

    AWS

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

    Note

    AWS [Sign in to a different account] [Createa new AWS account]

    2.

    PIN

    AWS

    IAM AWS (Amazon EC2 )

    19

    https://aws.amazon.com/free/https://aws.amazon.com/

  • Amazon Elastic Compute CloudLinux

    IAM

    AWS API AWS AWS AWS Identity and AccessManagement (IAM) IAM IAM URL IAM AWS

    AWS IAM IAM AWS

    IAM

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

    Note

    IAM

    2. [Users] [Add user] 3. [User name] Administrator 4. [AWS access] [Custom password]

    [Requirepassword reset] ()

    5. [Next: Permissions] 6. [Set permissions for user] [Add user to group] 7. [Create group] 8. [Create group] Administrators 9. [Filter] [Job function] 10. [AdministratorAccess] [Create group]

    11.

    [Refresh] 12. [Next: Review]

    [Create user]

    AWS AWS

    IAM AWS URL your_aws_account_id AWS ( AWS 1234-5678-9012 AWS ID 123456789012 )

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

    IAM (E ) your_user_name @ your_aws_account_id

    URL AWS ID IAM [Dashboard]

    20

    http://docs.aws.amazon.com/awsconsolehelpdocs/latest/gsg/getting-started.htmlhttp://docs.aws.amazon.com/awsconsolehelpdocs/latest/gsg/getting-started.htmlhttps://console.aws.amazon.com/iam/http://docs.aws.amazon.com/IAM/latest/UserGuide/id_root-user.htmlhttp://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 CloudLinux

    [Customize] () URL

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

    IAM IAM [IAM users sign-in link]

    IAM IAM Amazon EC2 (p. 519)

    AWS Linux SSH

    Amazon EC2 (p. 7)

    1. URL AWS 2. AWS [EC2] Amazon EC2 3.

    () ()

    21

  • Amazon Elastic Compute CloudLinux

    4. [NETWORK & SECURITY] [Key Pairs]

    Tip

    [Key Pairs]

    22

  • Amazon Elastic Compute CloudLinux

    5. [Create Key Pair] 6. [Create Key Pair] [Key pair name]

    [Create] (IAM ) -key-pairme-key-pair-useast2

    7. .pem

    Important

    8. Mac Linux SSH Linux

    chmod 400 your_user_name-key-pair-region_name.pem

    Amazon EC2 (p. 492)

    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/ PuTTY

    2. PuTTYgen ([Start] [All Programs] > [PuTTY] > [PuTTYgen] )

    3. [Type of key to generate] [ RSA]

    4. [Load] PuTTYgen .ppk .pem

    5. [Open] [OK]

    6. [Save private key] PuTTYgen [Yes]

    7. PuTTY .ppk

    23

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

  • Amazon Elastic Compute CloudLinux

    Virtual Private Cloud (VPC)

    Virtual Private Cloud (VPC) Amazon VPC AWS VPC (p. 24) VPC Amazon EC2 (p. 610) VPC

    Important

    EC2-Classic VPC VPC T2

    VPC

    1. https://console.aws.amazon.com/vpc/ Amazon VPC 2. VPC VPC

    3. VPC [VPC ] 4. [Step 1: Select a VPC Configuration] [VPC with a Single Public Subnet]

    [Select] 5. [Step 2: VPC with a Single Public Subnet] [VPC name] VPC

    [Create VPC] [OK]

    Amazon VPC Amazon VPC (Amazon VPC )

    SSH IP HTTP HTTPS

    (p. 7)

    IPv4 Amazon EC2 IPv4 IP ?:Check IP (ISP) IP IP

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

    24

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

  • Amazon Elastic Compute CloudLinux

    Tip

    Amazon VPC Amazon VPC Amazon VPC Amazon EC2 Amazon VPC VPC

    2.

    3. [Security Groups] 4. [Create Security Group] 5. (IAM )

    _SG_ me_SG_uswest2

    6. [VPC] VPC VPC VPC (*)

    25

    http://docs.aws.amazon.com/AmazonVPC/latest/GettingStartedGuide/SecurityGroup.htmlhttp://docs.aws.amazon.com/AmazonVPC/latest/GettingStartedGuide/SecurityGroup.html

  • Amazon Elastic Compute CloudLinux

    Note

    EC2-Classic VPC

    7. [Inbound] ( [Add Rule] ) [Create]

    [Type] [HTTP] [Source] [Anywhere] (0.0.0.0/0)

    [Type] [HTTPS] [Source] [Anywhere] (0.0.0.0/0)

    [Type] [SSH] [Source] [My IP] IPv4 [Custom] IPv4 CIDR CIDR IP /32 (203.0.113.25/32 ) (203.0.113.0/24)

    Warning

    IPv4 (0.0.0.0/0) SSH

    Linux Amazon EC2 (p. 502)

    26

  • Amazon Elastic Compute CloudLinux

    Amazon EC2 Linux

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

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

    (p. 27) (p. 28) 1: (p. 28) 2: (p. 29) 3: (p. 30) (p. 30)

    Amazon EBS-backed ( EBS )Amazon EC2

    27

    https://aws.amazon.com/free/

  • Amazon Elastic Compute CloudLinux

    1. (p. 28)2. (p. 29)3. (p. 30)

    Windows Windows Amazon EC2 Amazon EC2 Windows

    AWS Command Line Interface Using Amazon EC2 through the AWS CLI

    Amazon EC2 (p. 19)

    1: AWS Linux Launchingan Instance

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

    AmazonLinux AMI Amazon Linux 2 AMI HVM AMI [Free tier eligible]

    4. [Choose an Instance Type] t2.micro

    Note

    t2.micro T2 VPC AWS EC2-Classic VPC VPC [Review and Launch] [Next: Configure InstanceDetails]

    5. [Review and Launch] 6. [Review Instance Launch] [Security Groups]

    a. [Edit security groups] b. [Configure Security Group] [Select an existing security group]

    c. [Review and

    Launch]

    28

    http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/EC2_GetStarted.htmlhttp://docs.aws.amazon.com/cli/latest/userguide/cli-using-ec2.htmlhttp://docs.aws.amazon.com/AWSEC2/latest/UserGuide/launching-instance.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 CloudLinux

    2:

    7. [Review Instance Launch] [Launch] 8. [Choose an existing key pair]

    [Create a new key pair] [Download Key Pair]

    Warning

    [Proceed without a key pair]

    [Launch Instances] 9. [View Instances]

    10. [Instances]

    pending running DNS ([Public DNS (IPv4)] [Show/Hide Columns] () [Public DNS (IPv4)] )

    11. [Status Checks]

    2: Linux PuTTY SSH Amazon Linux AMILinux PuTTY Windows Linux (p. 375)SSH Linux (p. 370)

    Important

    .pem SSH (p. 888)

    Linux

    1. Java Java Install JavaEnable Java inyour web browser

    2. Amazon EC2 [Instances] 3. [Connect] 4. [A Java SSH client directly from my browser (Java required)] 5. Amazon EC2 DNS [Public DNS]

    [Launch SSH Client]

    a. [User name] ec2-user

    29

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

  • Amazon Elastic Compute CloudLinux

    3:

    b. [Private key path] (.pem) ()

    c. () [Store in browser cache] Amazon EC2

    6. [Yes] [Run] MindTerm

    7. MindTerm

    8. [No]

    Note

    [No] ()

    3: (p. 30)

    Important

    AWS shutting down terminated Stopping Instances

    1. [Instances]

    2. [Actions][Instance State][Terminate] 3. [Yes, Terminate]

    Amazon EC2

    Run Command EC2 : Amazon EC2 (p. 80)SystemsManager Remote Management (Run Command)

    30

    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/systems-manager/latest/userguide/execute-remote-commands.html

  • Amazon Elastic Compute CloudLinux

    CloudWatch AWSBilling and Cost Management

    EBS Amazon EBS (p. 731) Amazon EBS (p. 734)

    LAMP : Amazon Linux AMI LAMP (p. 44)

    31

    http://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/free-tier-alarms.html

  • Amazon Elastic Compute CloudLinux

    Amazon EC2 Amazon EC2

    ID IAM IAM AWS API AWS IAM IAM

    (p. 503)

    Amazon Linux (Linux ) Windows Windows Amazon EC2 Windows

    EC2-Classic VPC 2013 12 4 AWS VPC Amazon EC2 Amazon Virtual Private Cloud (p. 604)

    (p. 87)

    Amazon EBS Amazon EBS (p. 393)

    AWS (p. 425)Amazon EC2 (p. 867)

    Amazon EC2 Amazon EC2 (p. 876)

    Amazon EBS (p. 778) EBS Amazon Machine Image (AMI) (p. 85)

    32

    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/UserGuide/managing-software.htmlhttp://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/windows-ami-version-history.html#update-windows-instance

  • Amazon Elastic Compute CloudLinux

    IP Amazon EC2 IP (p. 633)

    Amazon EC2 (p. 442)

    Elastic IP Elastic Network Interface (p. 659) Amazon EC2 Auto Scaling AmazonEC2 Auto Scaling

    Amazon EBS

    33

    http://docs.aws.amazon.com/autoscaling/latest/userguide/http://docs.aws.amazon.com/autoscaling/latest/userguide/

  • Amazon Elastic Compute CloudLinux

    LAMP (Amazon Linux 2)

    Linux Amazon EC2

    Linux EC2 AWS Instructional Videos and Labs

    : Amazon Linux 2 LAMP (p. 34) : Amazon Linux AMI LAMP (p. 44) : Amazon Linux WordPress (p. 53) : Amazon Linux 2 SSL/TLS Apache

    (p. 62) : Amazon EC2 (p. 77) : Amazon EC2 (p. 80)

    : Amazon Linux 2 LAMP

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

    Amazon Linux AMI LAMP : Amazon Linux AMI LAMP (p. 44)

    Important

    Ubuntu Red Hat Enterprise Linux LAMP Ubuntu LAMP Ubuntu ApacheMySQLPHP

    1: LAMP

    DNS Amazon Linux2 1: (p. 28)SSH ( 22)HTTP ( 80)HTTPS ( 443) Amazon EC2 (p. 19)

    LAMP

    1. (p. 29)2.

    34

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

  • Amazon Elastic Compute CloudLinux

    1: LAMP

    -y

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

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

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

    Note

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

    cat /etc/system-release

    Amazon Linux AMI LAMP : AmazonLinux AMI LAMP (p. 44)

    4. Apache MariaDBPHP

    yum install

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

    Note

    yum info package_name

    5. Apache

    [ec2-user ~]$ sudo systemctl start httpd

    6. systemctl Apache

    [ec2-user ~]$ sudo systemctl enable httpd

    httpd

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

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

    a. https://console.aws.amazon.com/ec2/) Amazon EC2

    35

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

  • Amazon Elastic Compute CloudLinux

    1: LAMP

    b. [] c. [] [] d.

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

    (p. 509)

    [Type]: HTTP [Protocol]: TCP [Port Range]: 80 [Source]: Custom

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

    Apache HTTP (80) HTTP (p. 509)

    Important

    Amazon Linux

    36

  • Amazon Elastic Compute CloudLinux

    1: LAMP

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

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

    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 adm wheel apache systemd-journal

    3. /var/www apache

    37

  • Amazon Elastic Compute CloudLinux

    2: LAMP

    [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

    ()

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

    HTTPS : Amazon Linux SSL/TLS Apache

    2: LAMP ec2-user /var/www/html PHP

    LAMP

    1. Apache PHP

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

    (p. 37)

    2. URL URL DNS (:

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

    PHP

    38

    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 CloudLinux

    3:

    Note

    /var/www/html/phpinfo.php

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

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

    3. phpinfo.php

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

    LAMP /var/www/html Apache DNS

    3: MariaDB mysql_secure_installation

    39

  • Amazon Elastic Compute CloudLinux

    4: () phpMyAdmin

    MariaDB

    MariaDB

    1. MariaDB

    [ec2-user ~]$ sudo systemctl start mariadb

    2. mysql_secure_installation

    [ec2-user ~]$ sudo mysql_secure_installation

    a.

    i. Enter

    ii. Y 2 https://identitysafe.norton.com/password-generator/

    Note

    MariaDB

    b. Yc. Yd. Ye. Y

    3. () MariaDB

    [ec2-user ~]$ sudo systemctl stop mariadb

    4. () MariaDB

    [ec2-user ~]$ sudo systemctl enable mariadb

    4: () phpMyAdmin phpMyAdmin EC2 MySQL Amazon Linux phpMyAdmin

    Important

    Apache SSL/TLS LAMP phpMyAdmin

    40

    https://identitysafe.norton.com/password-generator/https://www.phpmyadmin.net/

  • Amazon Elastic Compute CloudLinux

    4: () phpMyAdmin

    Securing your phpMyAdmin installation EC2:Amazon Linux SSL/TLS Apache

    phpMyAdmin

    1.

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

    2. Apache

    [ec2-user ~]$ sudo systemctl restart httpd

    3. /var/www/html Apache

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

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

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

    5. phpMyAdmin

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

    6. phpMyAdmin-latest-all-languages.tar.gz Tarball

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

    7. () MySQL

    [ec2-user ~]$ sudo systemctl start mariadb

    8. phpMyAdmin URL URL DNS ( IP ) (:

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

    phpMyAdmin

    41

    https://docs.phpmyadmin.net/en/latest/setup.html#securing-your-phpmyadmin-installationhttp://docs.aws.amazon.com/AWSEC2/latest/UserGuide/SSL-on-an-instance.htmlhttp://docs.aws.amazon.com/AWSEC2/latest/UserGuide/SSL-on-an-instance.htmlhttps://www.phpmyadmin.net/downloads

  • Amazon Elastic Compute CloudLinux

    4: () phpMyAdmin

    9. root MySQL phpMyAdmin

    phpMyAdmin

    phpMyAdmin phpMyAdmin User Guide

    42

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

  • Amazon Elastic Compute CloudLinux

    LAMP

    Apache

    ?

    httpd

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

    httpd LAMP (p. 34)

    ?

    Apache HTTP ( 80)HTTP (p. 509)

    WordPress

    WinSCP Linux (p. 380) SCP Linux Linux (p. 372) : Amazon Linux WordPress (p. 53)

    Apache : 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

    Amazon Route53 Amazon Route 53

    43

    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 CloudLinux

    LAMP (Amazon Linux AMI)

    : Amazon Linux AMI LAMP

    Apache PHP MySQL Amazon Linux (LAMP LAMP )PHP

    Amazon Linux 2 LAMP : Amazon Linux 2 LAMP (p. 34)

    Important

    Ubuntu Red Hat Enterprise Linux LAMP Ubuntu LAMP Ubuntu ApacheMySQLPHP

    DNS Amazon LinuxAMI 1: (p. 28)SSH ( 22)HTTP ( 80)HTTPS ( 443) Amazon EC2 (p. 19)

    Amazon Linux AMI LAMP

    1. (p. 29)2.

    -y

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

    3. Apache MySQLPHP

    Note

    LAMP PHP (p. 52)

    yum install

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

    4. Apache

    44

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

  • Amazon Elastic Compute CloudLinux

    LAMP (Amazon Linux AMI)

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

    5. chkconfig Apache

    [ec2-user ~]$ sudo chkconfig httpd on

    chkconfig

    httpd

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

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

    [launch-wizard-N] SSH

    a. https://console.aws.amazon.com/ec2/) Amazon EC2 b. [] c. [] [] d.

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

    (p. 509)

    [Type]: HTTP [Protocol]: TCP [Port Range]: 80 [Source]: Custom

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

    Apache HTTP (80) HTTP (p. 509)

    Important

    Amazon Linux

    45

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

  • Amazon Elastic Compute CloudLinux

    LAMP (Amazon Linux AMI)

    Note

    /var/www/html DNS

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

    [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

    46

  • Amazon Elastic Compute CloudLinux

    LAMP (Amazon Linux AMI)

    ec2-user apache /var/www apache

    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

    ()

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

    HTTPS : Amazon Linux SSL/TLS Apache

    LAMP

    ec2-user /var/www/html PHP

    1. Apache PHP

    47

    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 CloudLinux

    LAMP (Amazon Linux AMI)

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

    (p. 47)

    2. URL URL DNS (:

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

    PHP

    /var/www/html/phpinfo.php (2 )

    [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

    48

  • Amazon Elastic Compute CloudLinux

    LAMP (Amazon Linux AMI)

    3. phpinfo.php

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

    MySQL mysql_secure_installation MySQL

    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. Enter

    ii. Y 2 https://identitysafe.norton.com/password-generator/

    Note

    MySQL

    b. Yc. Yd. Ye. Y

    3. () MySQL

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

    4. () MySQL

    [ec2-user ~]$ sudo chkconfig mysqld on

    49

    https://identitysafe.norton.com/password-generator/

  • Amazon Elastic Compute CloudLinux

    LAMP (Amazon Linux AMI)

    LAMP /var/www/html Apache DNS

    () phpMyAdmin

    phpMyAdmin EC2 MySQL Amazon Linux phpMyAdmin

    Important

    Apache SSL/TLS LAMP phpMyAdmin Securing your phpMyAdmin installation EC2 : AmazonLinux SSL/TLS Apache

    Note

    Amazon Linux PHP 7 phpMyAdmin phpMyAdmin

    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.

    [ec2-user html]$ tar -xvzf phpMyAdmin-latest-all-languages.tar.gz[ec2-user html]$ mv phpMyAdmin-4.7.5-all-languages phpMyAdmin

    7. () MySQL

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

    50

    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.htmlhttp://docs.aws.amazon.com/AWSEC2/latest/UserGuide/SSL-on-an-instance.htmlhttps://www.phpmyadmin.net/downloads

  • Amazon Elastic Compute CloudLinux

    LAMP (Amazon Linux AMI)

    8. phpMyAdmin URL URL DNS ( IP ) (:

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

    phpMyAdmin

    51

  • Amazon Elastic Compute CloudLinux

    9. root MySQL phpMyAdmin

    phpMyAdmin

    phpMyAdmin phpMyAdmin User Guide

    LAMP

    Apache

    ?

    httpd

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

    httpd 234 5 on ()

    httpd Amazon Linux AMI LAMP (p. 44)

    ?

    Apache HTTP ( 80)HTTP (p. 509)

    PHP Apache HTTP ServerPHPMySQL LAMP PHP ()PHP PHP AmazonLinux AMI 2016.09 Release Notes

    LAMP

    httpd24

    52

    https://docs.phpmyadmin.net/en/latest/setup.html#manually-creating-the-filehttps://docs.phpmyadmin.net/en/latest/setup.html#manually-creating-the-filehttps://docs.phpmyadmin.net/en/latest/setup.html#using-setup-scripthttp://docs.phpmyadmin.net/en/latest/user.htmlhttps://aws.amazon.com/amazon-linux-ami/2016.09-release-notes/https://aws.amazon.com/amazon-linux-ami/2016.09-release-notes/

  • Amazon Elastic Compute CloudLinux

    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

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

    WordPress

    WinSCP Linux (p. 380) SCP Linux Linux (p. 372) : Amazon Linux WordPress (p. 53)

    Apache : 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

    Amazon Route53 Amazon Route 53

    : Amazon Linux WordPress

    Amazon Linux WordPress WordPress

    53

    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.html

  • Amazon Elastic Compute CloudLinux

    () AmazonEC2

    WordPress AWS CloudFormation WordPress AWS CloudFormation Windows WordPress Windows Amazon EC2 Deploying a WordPress Blog on Your Amazon EC2 Windows InstanceAWS ElasticBeanstalk WordPress

    Important

    Amazon Linux Ubuntu Ubuntu WordPress Ubuntu WordPress

    Amazon Linux AMI : Amazon Linux AMI LAMP (p. 44) Amazon Linux 2 : AmazonLinux 2 LAMP (p. 34)PHP (MySQL MariaDB) Amazon Linux HTTP HTTPS (p. 509)

    Elastic IP (EIP) WordPress DNS EIP DNS () EIP 1 Elastic IP (p. 650)

    Route53 EIP Amazon Route53 AmazonRoute 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

    54

    http://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/WordPresshttp://docs.aws.amazon.com/Route53/latest/DeveloperGuide/registrar.htmlhttp://docs.aws.amazon.com/Route53/latest/DeveloperGuide/registrar.html

  • Amazon Elastic Compute CloudLinux

    WordPress

    WordPress

    WordPress

    1.

    Amazon Linux AMI: sudo service mysqld start Amazon Linux 2: sudo systemctl start mariadb

    2. root root root

    Important

    (p. 49)

    [ec2-user ~]$ mysql -u root -p

    3. MySQL WordPress MySQL

    CREATE USER 'wordpress-user'@'localhost' IDENTIFIED BY 'your_strong_password';

    (') http://www.pctools.com/guides/password/

    4. wordpress-db

    Note

    (`) Tab ()

    CREATE DATABASE `wordpress-db`;

    5. WordPress

    GRANT ALL PRIVILEGES ON `wordpress-db`.* TO "wordpress-user"@"localhost";

    6.

    FLUSH PRIVILEGES;

    7. mysql

    exit

    55

    http://www.pctools.com/guides/password/

  • Amazon Elastic Compute CloudLinux

    WordPress

    wp-config.php

    WordPress wp-config-sample.php

    1. wp-config-sample.php wp-config.php

    [ec2-user wordpress]$ cp wordpress/wp-config-sample.php wordpress/wp-config.php

    2. (wp-config.phpnanovim ) nano

    [ec2-user wordpress]$ nano wordpress/wp-config.php

    a. DB_NAME database_name_here Step 4 (p. 55) WordPress (p. 55)

    define('DB_NAME', 'wordpress-db');

    b. DB_USER username_here Step 3 (p. 55) WordPress (p. 55)

    define('DB_USER', 'wordpress-user');

    c. DB_PASSWORD password_here Step 3 (p. 55) WordPress (p. 55)

    define('DB_PASSWORD', 'your_strong_password');

    d. Authentication Unique Keys and Salts KEY SALT WordPress https://api.wordpress.org/secret-key/1.1/salt/ wp-config.php PuTTY PuTTY

    http://codex.wordpress.org/Editing_wp-config.php#Security_Keys

    Note

    define('AUTH_KEY', ' #U$$+[RXN8:b^-L 0(WU_+ c+WFkI~c]o]-bHw+)/Aj[wTwSiZ)Y |;(^[Iw]Pi+LG#A4R?7N`YB3');

    56

    https://api.wordpress.org/secret-key/1.1/salt/http://codex.wordpress.org/Editing_wp-config.php#Security_Keyshttp://codex.wordpress.org/Editing_wp-config.php#Security_Keys

  • Amazon Elastic Compute CloudLinux

    WordPress

    define('NONCE_KEY', 'P(g62HeZxEes|LnI^i=H,[XwK9I&[2s|:?0N}VJM%?;v2v]v+;+^9eXUahg@::Cj');define('AUTH_SALT', 'C$DpB4Hj[JK:?{ql`sRVa:{:7yShy(9A@5wg+`JJVb1fk%_-Bx*M4(qc[Qg%JT!h');define('SECURE_AUTH_SALT', 'd!uRu#}+q#{f$Z?Z9uFPG.${+S{n~1M&%@~gL>U>NV.|Y%Ug4#I^*LVd9QeZ^&XmK|e(76miC+&W&+^0P/');define('NONCE_SALT', '-97r*V/cgxLmp?Zy4zUU4r99QQ_rGs2LTd%P;|_e1tS)8_B/,.6[=UK

  • Amazon Elastic Compute CloudLinux

    WordPress

    Possible values for the Options directive are "None", "All", or any combination of: Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews Note that "MultiViews" must be named *explicitly* --- "Options All" doesn't give it to you. The Options directive is both complicated and important. Please see http://httpd.apache.org/docs/2.4/mod/core.htmloptions for more information. Options Indexes FollowSymLinks

    AllowOverride controls what directives may be placed in .htaccess files. It can be "All", "None", or any combination of the keywords: Options FileInfo AuthConfig Limit AllowOverride None

    Controls who can get stuff from this server. Require all granted

    3. AllowOverride None AllowOverride All

    Note

    AllowOverride

    AllowOverride All

    4.

    Apache

    WordPress Apache () (LAMP (p. 44))

    1. /var/www apache

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

    2. /var/www apache

    [ec2-user wordpress]$ sudo chgrp -R apache /var/www

    3. /var/www ID

    [ec2-user wordpress]$ sudo chmod 2775 /var/www

    4. /var/www

    58

  • Amazon Elastic Compute CloudLinux

    WordPress

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

    5. Apache

    [Amazon Linux AMI]: sudo service httpd restart [Amazon Linux 2]: sudo systemctl restart httpd

    WordPress

    1. chkconfig httpd

    [Amazon Linux AMI]: sudo chkconfig enable httpd && sudo chkconfig enable mysql [Amazon Linux 2]: sudo systemctl enable httpd && sudo systemctl enable mariadb

    2.

    [Amazon Linux AMI]: sudo service mysqld status [Amazon Linux 2]: sudo systemctl status mariadb

    Amazon Linux AMI: sudo service mysqld start Amazon Linux 2: sudo systemctl start mariadb

    3. Apache (httpd)

    [Amazon Linux AMI]: sudo service httpd status [Amazon Linux 2]: sudo systemctl status httpd

    httpd

    [Amazon Linux AMI]: sudo service httpd start [Amazon Linux 2]: sudo systemctl start httpd

    4. WordPress URL ( DNS blog )WordPress

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

    59

  • Amazon Elastic Compute CloudLinux

    5. WordPress