azure运行linux,快速入门 - 在 Azure 门户中创建 Linux VM - Azure Linux Virtual Machines | Azure Docs...

本文提供了一个快速入门指南,详细介绍了如何使用Azure门户在中国东部2区创建一个运行Ubuntu 18.04 LTS的Linux虚拟机(VM),包括设置SSH公钥、入站端口规则和安装NGINX Web服务器。完成部署后,你可以通过SSH连接到VM并查看运行中的Web服务器。最后,了解了如何清理资源,删除不再需要的虚拟机及其相关资源。
摘要由CSDN通过智能技术生成

快速入门:在 Azure 门户中创建 Linux 虚拟机Quickstart: Create a Linux virtual machine in the Azure portal

12/01/2020

本文内容

可以通过 Azure 门户创建 Azure 虚拟机 (VM)。Azure virtual machines (VMs) can be created through the Azure portal. Azure 门户是基于浏览器的用户界面,用于创建 Azure 资源。The Azure portal is a browser-based user interface to create Azure resources. 本快速入门介绍如何使用 Azure 门户部署运行 Ubuntu 18.04 LTS 的 Linux 虚拟机 (VM)。This quickstart shows you how to use the Azure portal to deploy a Linux virtual machine (VM) running Ubuntu 18.04 LTS. 若要查看运行中的 VM,也可以通过 SSH 登录到该 VM 并安装 NGINX Web 服务器。To see your VM in action, you also SSH to the VM and install the NGINX web server.

如果没有 Azure 订阅,可在开始前创建一个试用帐户。If you don't have an Azure subscription, create a Trial before you begin.

登录 AzureSign in to Azure

如果尚未登录到 Azure 门户,请进行登录。Sign in to the Azure portal if you haven't already.

创建虚拟机Create virtual machine

在搜索中键入“虚拟机”。Type virtual machines in the search.

在“服务”下,选择“虚拟机” 。Under Services, select Virtual machines.

在“虚拟机”页上,选择“添加” 。In the Virtual machines page, select Add. 此时将打开“创建虚拟机”页。The Create a virtual machine page opens.

在“基本信息”选项卡中的“项目详细信息”下,确保选择了正确的订阅,然后选择 新建 资源组。In the Basics tab, under Project details, make sure the correct subscription is selected and then choose to Create new resource group. 对于名称.*,请键入 myResourceGroup。Type myResourceGroup for the name.*.

91e5c51c48cc6eafed8daceba4a21c58.png

在“实例详细信息”下,键入“myVM”作为“虚拟机名称”,选择“中国东部 2”作为“区域”,并选择“Ubuntu 18.04 LTS”作为“映像”。Under Instance details, type myVM for the Virtual machine name, choose China East 2 for your Region, and choose Ubuntu 18.04 LTS for your Image. 保留其他默认值。Leave the other defaults.

c30aee3901c62f70fb8c244ab955f1da.png

在“管理员帐户” 下,选择“SSH 公钥” ,键入用户名,然后粘贴公钥。Under Administrator account, select SSH public key, type your user name, then paste in your public key. 删除公钥中任何开头或结尾处的空格。Remove any leading or trailing white space in your public key.

62849766d40f3e83205d9d3c60e79775.png

在“入站端口规则” > “公共入站端口”下,选择“允许所选端口”,然后从下拉列表中选择“SSH (22)”和“HTTP (80)”。Under Inbound port rules > Public inbound ports, choose Allow selected ports and then select SSH (22) and HTTP (80) from the drop-down.

d307f53fb3f0d517f4de5f025feb48ad.png

保留其余默认值,然后选择页面底部的“查看 + 创建”按钮。Leave the remaining defaults and then select the Review + create button at the bottom of the page.

在“创建虚拟机”页上,可以查看要创建的 VM 的详细信息。On the Create a virtual machine page, you can see the details about the VM you are about to create. 准备好以后,选择“创建”。When you are ready, select Create.

部署完成后,选择“转到资源”。When the deployment is finished, select Go to resource.

在新 VM 的页面上,选择公共 IP 地址并将其复制到剪贴板。On the page for your new VM, select the public IP address and copy it to your clipboard.

6ea062941b05800f0683d14cba2351ea.png

连接到虚拟机Connect to virtual machine

创建与 VM 的 SSH 连接。Create an SSH connection with the VM.

如果使用的是 Mac 或 Linux 计算机,请打开 Bash 提示符。If you are on a Mac or Linux machine, open a Bash prompt. 如果使用的是 Windows 计算机,请打开 PowerShell 提示符。If you are on a Windows machine, open a PowerShell prompt.

根据提示符,打开与虚拟机的 SSH 连接。At your prompt, open an SSH connection to your virtual machine. 将 IP 地址替换为 VM 中的 IP 地址,并将 .pem 的路径替换为密钥文件的下载路径。Replace the IP address with the one from your VM, and replace the path to the .pem with the path to where the key file was downloaded.

ssh -i .\Downloads\myKey1.pem azureuser@10.111.12.123

安装 Web 服务器Install web server

若要查看运行中的 VM,请安装 NGINX Web 服务器。To see your VM in action, install the NGINX web server. 在 SSH 会话中更新包源,然后安装最新的 NGINX 包。From your SSH session, update your package sources and then install the latest NGINX package.

sudo apt-get -y update

sudo apt-get -y install nginx

完成后,键入 exit 以离开 SSH 会话。When done, type exit to leave the SSH session.

查看运行中的 Web 服务器View the web server in action

使用所选的 Web 浏览器查看默认的 NGINX 欢迎页。Use a web browser of your choice to view the default NGINX welcome page. 键入 VM 的公共 IP 地址作为 Web 地址。Type the public IP address of the VM as the web address. 可以在 VM 概览页上或此前使用过的 SSH 连接字符串中找到公共 IP 地址。The public IP address can be found on the VM overview page or as part of the SSH connection string you used earlier.

97f1a3bde521809dd52310d4c42259c1.png

清理资源Clean up resources

当不再需要时,可以删除资源组、虚拟机和所有相关资源。When no longer needed, you can delete the resource group, virtual machine, and all related resources. 为此,请选择虚拟机的资源组,选择“删除”,然后确认要删除的资源组的名称。To do so, select the resource group for the virtual machine, select Delete, then confirm the name of the resource group to delete.

后续步骤Next steps

在本快速入门中,你部署了一台简单的虚拟机、一条网络安全组规则组和规则,并安装了一台基本 Web 服务器。In this quickstart, you deployed a simple virtual machine, created a Network Security Group and rule, and installed a basic web server. 若要详细了解 Azure 虚拟机,请继续学习 Linux VM 的教程。To learn more about Azure virtual machines, continue to the tutorial for Linux VMs.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值