Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
É possível controlar uma instância de máquina virtual (VM) no Compute Engine como qualquer
servidor Windows padrão. Neste tutorial, você verá como implantar um servidor da Web do IIS simples
para aprender os conceitos básicos da execução de um servidor da Web em uma VM.
Antes de começar
Você precisa de uma nova instância do Windows com permissão para tráfego HTTP.
Siga as instruções no Guia de início rápido para criar uma nova instância do Windows e conectar-se a ela com o RDP.
Instalar o IIS
No campo de pesquisa da barra de tarefas do Windows, digite PowerShell e
pressione Enter. Se este campo não existir, clique no ícone de
pesquisa, digite PowerShell e pressione Enter. Se o campo e o ícone
de pesquisa não aparecerem na barra de tarefas, acesse Localização da caixa de pesquisa
no Windows.
Nos resultados da pesquisa, em Apps, clique com o botão direito do mouse em Windows PowerShell
e escolha Executar como administrador.
Instale os serviços do IIS com os comandos a seguir:
Visualize a página Hello World! copiando o endereço IP da coluna IP
externo e colando-o em uma nova guia do navegador. Se a página Hello
World! não aparecer, siga as etapas de solução de problemas.
Limpeza
Quando terminar os testes, siga as instruções de limpeza em "Início rápido" para evitar que cobranças sejam feitas para essa instância.
Solução de problemas
Recebimento de um erro Connection Refused
Se você está vendo um erro Connection Refused, isso pode estar acontecendo por conta de um destes motivos:
A instância de VM não está acessível publicamente porque as regras ou as tags de firewall estão configuradas incorretamente de uma das maneiras a seguir:
A instância da VM não tem a tag apropriada que permite que o Compute Engine aplique as regras de firewall adequadas à instância.
O projeto não tem uma regra de firewall que permita o tráfego para o endereço IP externo da instância.
Você está tentando acessar a VM com um endereço https. Verifique se o URL é http://[EXTERNAL_IP] em vez de https://[EXTERNAL_IP].
Para garantir que sua instância de VM tenha as tags corretas, faça o seguinte:
No console do Google Cloud, acesse a página Instâncias de VMs.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-04-22 UTC."],[[["\u003cp\u003eThis tutorial guides you through deploying a basic IIS web server on a Compute Engine virtual machine (VM) instance, similar to a standard Windows server.\u003c/p\u003e\n"],["\u003cp\u003eYou'll need to set up a new Windows VM instance, and ensure HTTP traffic is allowed before installing IIS and related services using PowerShell commands.\u003c/p\u003e\n"],["\u003cp\u003eAfter installing IIS, the default web page is overwritten with a "Hello World!" page using a command line entry.\u003c/p\u003e\n"],["\u003cp\u003eThe newly set up server is then tested by accessing the VM's external IP address in a browser to verify that the "Hello World!" page is properly displayed.\u003c/p\u003e\n"],["\u003cp\u003eTroubleshooting tips are included to address "Connection Refused" errors, highlighting the importance of proper firewall configurations, and confirming that traffic is being sent over \u003ccode\u003ehttp\u003c/code\u003e rather than \u003ccode\u003ehttps\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Running a basic IIS web server\n\n*** ** * ** ***\n\nYou can control a virtual machine (VM) instance on Compute Engine like any\nstandard Windows server. This tutorial shows you how to deploy a simple IIS web\nserver so you can learn the basics of running a web server on a VM.\n\nBefore you begin\n----------------\n\nYou'll need a new Windows instance with HTTP traffic allowed.\n\n- Follow the [Quickstart](/compute/docs/create-windows-server-vm-instance) instructions to create a new Windows instance and connect to it with RDP. \n\nInstall IIS\n-----------\n\n1. On the Windows taskbar, in the search field, type `PowerShell` and then\n press `Enter`. If there is no search field on the taskbar, click the search\n icon, type `PowerShell`, and then press `Enter`. If neither the search field\n nor the search icon appear on the taskbar, see [Hide and unhide your search\n box in Windows](https://support.microsoft.com/en-us/help/4028221/windows-10-locating-the-search-box-in-windows-10).\n\n2. In the search results, under **Apps** , right-click **Windows PowerShell** ,\n and choose **Run as administrator**.\n\n3. Install IIS services with the following commands:\n\n ```\n import-module servermanager\n ``` \n\n ```\n add-windowsfeature web-server -includeallsubfeature\n ```\n4. Overwrite the IIS web server default web page with the following command:\n\n ```\n echo '\u003c!doctype html\u003e\u003chtml\u003e\u003cbody\u003e\u003ch1\u003eHello World!\u003c/h1\u003e\u003c/body\u003e\u003c/html\u003e' \u003e C:\\inetpub\\wwwroot\\index.html\n ```\n\nTest your server\n----------------\n\nTest that your instance is serving traffic on its external IP:\n\n1. In the Google Cloud console, go to the **VM instances** page.\n\n [Go to VM instances](https://console.cloud.google.com/compute/instances)\n2. View the `Hello World!` page by copying the IP address from the **External\n IP** column and pasting it into a new browser tab. If you do not see the `Hello\n World!` page, follow the [Troubleshooting steps](/compute/docs/tutorials/basic-webserver-iis#troubleshooting).\n\nClean up\n--------\n\nWhen you're done experimenting, follow the clean up instructions in the\n[Quickstart](/compute/docs/create-windows-server-vm-instance#clean-up) to avoid incurring\ncharges for this instance.\n\nTroubleshooting\n---------------\n\n**Receiving a `Connection Refused` error**\n\nIf you are seeing a `Connection Refused` error, it is possible that:\n\n- Your VM instance is not publicly accessible because your firewall rules or\n tags are misconfigured in one of the following ways:\n\n - The VM instance does not have the proper tag that allows Compute Engine to apply the appropriate firewall rules to your instance.\n - Your project does not have a firewall rule that allows traffic to the external IP address for your instance.\n- You are trying to access the VM using an `https` address. Check that your\n URL is `http://[EXTERNAL_IP]` rather than `https://[EXTERNAL_IP]`.\n\nTo ensure that your VM instance has the correct tags:\n\n1. In the Google Cloud console, go to the **VM instances** page.\n\n [Go to VM instances](https://console.cloud.google.com/compute/instances)\n2. Click the name of the instance that you are trying to connect to.\n3. Click **Edit** at the top of the page.\n4. Scroll down to **Firewalls** , and make sure the **Allow HTTP traffic** box is checked. If it is not checked, check it.\n5. Save your changes. This ensures that the correct tags are added to the VM instance.\n\nTo ensure that the correct firewall rule exists:\n\n1. In the Google Cloud console, go to the **Firewall rules** page.\n\n [Go to Firewall rules](https://console.cloud.google.com/networking/firewalls)\n2. Look for a firewall rule that allows all IP ranges through tcp:80. Usually, this rule is named the `default-allow-http` rule.\n3. If a rule does not exist, create one.\n 1. Click **Create firewall rule**.\n 2. Enter a name for the rule, such as `default-allow-http`.\n 3. Under **Source IP ranges** , enter `0.0.0.0/0` to allow traffic from all sources.\n 4. Under **Protocols and ports** , check **Specified protocols and ports** and enter `tcp:80`.\n 5. Create your firewall rule.\n\nTest your server again by going to the external IP address of the instance: \n\n http://[EXTERNAL_IP]"]]