Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Vous pouvez contrôler une instance de machine virtuelle (VM) sur Compute Engine comme tout serveur Windows standard. Ce tutoriel explique comment déployer un serveur Web IIS élémentaire afin d'apprendre les bases de l'exécution d'un serveur Web sur une VM.
Avant de commencer
Vous avez besoin d'une nouvelle instance Windows avec le trafic HTTP autorisé.
Suivez les instructions de démarrage rapide pour créer une instance Windows et vous y connecter avec RDP.
Installer IIS
Dans le champ de recherche de la barre des tâches de Windows, saisissez PowerShell, puis appuyez sur la touche Enter. Si la barre des tâches ne comporte aucun champ de recherche, cliquez sur l'icône de recherche, saisissez PowerShell, puis appuyez sur la touche Enter. Si la barre des tâches ne comporte ni champ de recherche, ni icône de recherche, consultez l'article Recherche de la zone de recherche dans Windows 10.
Dans les résultats de recherche, sous Applications, effectuez un clic droit sur Windows PowerShell, puis sélectionnez Exécuter en tant qu'administrateur.
Installez les services IIS à l'aide des commandes suivantes :
Affichez la page Hello World! en copiant l'adresse IP qui figure dans la colonne Adresse IP externe et en la collant dans un nouvel onglet de navigateur. Si vous ne voyez pas la page Hello
World!, suivez les étapes de dépannage.
Nettoyer
Lorsque vous avez terminé vos tests, suivez les instructions de nettoyage du démarrage rapide afin d'éviter de payer des frais pour cette instance.
Dépannage
Réception d'une erreur Connection Refused
Une erreur Connection Refused peut s'afficher dans les cas suivants :
Votre instance de VM n'est pas accessible au public, car la configuration de vos règles de pare-feu ou de vos tags ne respecte pas l'un des paramètres suivants :
L'instance de VM ne dispose pas du tag approprié permettant à Compute Engine d'appliquer les règles de pare-feu associées à votre instance.
Votre projet ne dispose pas d'une règle de pare-feu autorisant le trafic vers l'adresse IP externe de votre instance.
Vous tentez d'accéder à la VM à l'aide d'une adresse https. Vérifiez que votre URL est de type http://[EXTERNAL_IP] et non https://[EXTERNAL_IP].
Pour vous assurer que votre instance de VM dispose des bons tags, procédez comme suit :
Dans Google Cloud Console, accédez à la page Instances de VM.
Recherchez une règle de pare-feu qui autorise toutes les plages IP via le port tcp:80. Cette règle est généralement appelée règle default-allow-http.
Si aucune règle n'existe, créez-en une.
Cliquez sur Créer une règle de pare-feu.
Saisissez un nom pour la règle, par exemple default-allow-http.
Sous Plages d'adresses IP sources, saisissez 0.0.0.0/0 pour autoriser le trafic provenant de toutes les sources.
Sous Protocoles et ports, cochez la case Protocoles et ports spécifiés, puis saisissez tcp:80.
Créez votre règle de pare-feu.
Testez à nouveau votre serveur en accédant à l'adresse IP externe de l'instance :
http://[EXTERNAL_IP]
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/04/22 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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]"]]