# Amazon EC2 進到 AWS 首頁,右上方 "我的帳戶"(My Account)下拉選單, 點擊 "AWS 管理控制台"(AWS Management Console)。 ![a1](https://i.imgur.com/rgaYK6O.png) > --- AWS 服務 > 所有服務(運算)> EC2。 ![a2](https://i.imgur.com/ggiXtLF.png) > --- 登入: > 選 "IAM User" > 輸入帳號 ID (12碼) > Next ![a3](https://i.imgur.com/a1oAmjT.png) > --- 繼續輸入帳號資訊 > IAM 使用著名稱 > 輸入密碼 > sign in ![a4](https://i.imgur.com/eF1BBss.png) > --- 等待登入跳轉中... ![a5](https://i.imgur.com/wGbzeHF.png) > --- 登入畫面(由於此帳號有做過項目,如帳號是新建的,執行個體..等,數量應都為零。) ![a6](https://i.imgur.com/vV7CyeS.png) --- ## 啟動執行個體 - 在 https://console.aws.amazon.com/ec2/ 開啟 Amazon EC2 主控台。 ![a111](https://i.imgur.com/JcgAwMo.png) > --- - 請在主控台儀表板選擇 Launch Instance (啟動執行個體)。 ![a121](https://i.imgur.com/ExPpI17.png) > --- - Choose an Amazon Machine Image (AMI) (選擇 Amazon Machine Image (AMI)) 頁面會顯示基本的組態清單,稱為 Amazon Machine Image (AMI),作用如同您執行個體的範本。選取 HVM 版本的 Amazon Linux 2。 請注意,這些 AMI 會帶有 "Free tier eligible" (符合免費方案) 的標記。 ![a131](https://i.imgur.com/lzoqKr5.png) > 選擇 "Ubuntu Server 18.04 LTS (HVM), SSD Volume Type" ![a141](https://i.imgur.com/D55mkKE.png) > --- - 在 Choose an Instance Type (選擇執行個體類型) 頁面中,您可以選取您執行個體的硬體組態。選取 t2.micro 執行個體類型,其預設為選取。t2.micro 執行個體類型符合免費方案資格。在無法使用 t2.micro 的區域中,您可以根據免費方案使用 t3.micro 執行個體。如需詳細資訊,請參閱 AWS 免費方案。 ![a151](https://i.imgur.com/5Tet9SO.png) - 選擇 Review and Launch (檢閱和啟動),讓精靈為您完成其他的組態設定。 > --- - 在 Review Instance Launch (檢閱執行個體啟動) 頁面的 Security Groups (安全群組) 下,您會看到精靈為您建立並選取的安全群組。您可使用此安全群組,或者使用下列步選取您在設定時建立的安全群組: a. 選擇 Edit security groups (編輯安全群組)。 ![a161](https://i.imgur.com/ZopFvCl.png) b. 在 Configure Security Group (設定安全群組) 頁面上,確定選取 Select an existing security group (選取現有的安全群組)。 ![a162](https://i.imgur.com/W2uPSRB.png) c. 從現有的安全群組清單中選取您的安全群組,然後選擇 Review and Launch (檢閱和啟動)。 - 在 Review Instance Launch (檢閱執行個體啟動) 頁面,選擇 Launch (啟動)。 ![a171](https://i.imgur.com/MTZHcTG.png) > --- - 當系統提示要求金鑰對時,請選取 Choose an existing key pair (選擇現有金鑰對),然後選取您在設定時建立的金鑰對。 ![a181](https://i.imgur.com/YtNV5IV.png) > --- ![](https://i.imgur.com/ragmcp2.png) > --- ![](https://i.imgur.com/EOPWNWv.png) > --- ## 連線到您的執行個體 有幾種方法可連線至 Linux 執行個體。如需詳細資訊,請參閱 [連接至您的 Linux 執行個體](https://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html)。 > ### **[重要]** > 除非您使用有其 .pem 檔的金鑰對,而且從您的電腦用允許 SSH 存取的安全群組啟動執行個體,否則您無法連線至您的執行個體。 如果您無法連線至您的執行個體,請參閱 [連線到執行個體的故障診斷](https://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/TroubleshootingInstancesConnecting.html) 取得協助。 > --- ![a211](https://i.imgur.com/vEglAHb.png) > $ ssh -i ~/[key_pair_name].pem  ubuntu@[IP] ![a212](https://i.imgur.com/ChSyurm.png) > --- ## 清理您的執行個體 在您完成為本教學建立的執行個體後,您應該終止此執行個體完成清理。如果想在清理前使用此執行個體執行更多作業,請參閱 [後續步驟]。 > ### **[重要]** >終止執行個體可有效的將其刪除,無法在終止執行個體後重新連接到執行個體。 如果啟動不在 [AWS 免費方案](https://aws.amazon.com/free/) 內的執行個體,執行個體狀態一變更至 shutting down 或 terminated 就會立即停止產生費用。若要保留執行個體以待後用,但不想產生費用,您可立即停止執行個體,稍後再啟動它。如需詳細資訊,請參閱 [停止和啟動執行個體](https://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/Stop_Start.html)。 #### 終止指定執行個體 在導覽窗格中,選擇 Instances (執行個體)。在執行個體清單中,選取執行個體。 ![](https://i.imgur.com/Xeglr4T.png) --- ![](https://i.imgur.com/PrzX5Q4.png) >--- 選擇 Instance state (執行個體狀態)、Terminate instance (終止執行個體)。 ![](https://i.imgur.com/dy6EctN.png) >--- 出現確認提示時,請選擇 Terminate (終止)。 ![](https://i.imgur.com/9tCs8rW.png) >--- Amazon EC2 關閉並終止您的執行個體。在您的執行個體終止後,它仍會短暫顯示於主控台,然後項目才會自動刪除。您無法自行從主控台顯示畫面中移除已終止的執行個體。 ![](https://i.imgur.com/KxGmIrn.png) >--- 等待約 3-5 分鐘,被終止的執行個體,已自動刪除。 ![](https://i.imgur.com/cluRrzb.png) --- ## 後續步驟 在啟動執行個體後,建議嘗試下列部分練習: - 了解如何使用 Run Command 從遠端管理您的 EC2 執行個體。如需詳細資訊,請參閱 ***AWS Systems Manager 使用者指南*** 中的 **[AWS Systems Manager Run Command](https://docs.aws.amazon.com/systems-manager/latest/userguide/execute-remote-commands.html)**。 - 設定 CloudWatch 警示當使用超出免費方案時通知您。如需詳細資訊,請參閱 ***AWS Billing and Cost Management 使用者指南*** 中的 **[追蹤 AWS 免費方案用量](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/tracking-free-tier-usage.html)**。 - 新增 EBS 磁碟區。如需更多詳細資訊,請參閱 **[建立 Amazon EBS 磁碟區](https://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ebs-creating-volume.html)** 及 **[將 Amazon EBS 磁碟區連接至執行個體](https://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ebs-attaching-volume.html)**。 - 安裝 LAMP 堆疊。如需更多詳細資訊,請參閱 **[教學:在 Amazon Linux 2 上安裝 LAMP Web 伺服器](https://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/ec2-lamp-amazon-linux-2.html)**。 --- ## 參考: - Remotely Run Commands on an EC2 Instance https://aws.amazon.com/getting-started/hands-on/remotely-run-commands-ec2-instance-systems-manager/ - install-apache-with-php-and-mysql-on-ubuntu-18-04-lamp https://www.howtoforge.com/tutorial/install-apache-with-php-and-mysql-on-ubuntu-18-04-lamp/ - Amazon Elastic Compute Cloud Documentation https://docs.aws.amazon.com/ec2/ Amazon Kinesis Video Streams 透過 WebRTC 新增即時雙向媒體串流支援