[Yandex Cloud documentation](../../../index.md) > [Tutorials](../../index.md) > Application solutions > Creating a website > [Website based on LAMP or LEMP stack](index.md) > Management console

# Website on a LAMP or LEMP stack using the management console

To create an infrastructure for a [website on a LAMP or LEMP stack](index.md) using the Yandex Cloud management console:

1. [Get your cloud ready](#before-you-begin).
1. [Create a cloud network and subnets](#create-network).
1. [Create a security group](#create-security-groups).
1. [Create a VM with a pre-installed web server](#create-vm).
1. [Upload the website files](#upload-files).
1. [Configure DNS](#configure-dns).
1. [Test the website](#test-site).

We will use the `example.com` domain name as an example.

If you no longer need the resources you created, [delete them](#clear-out).

## Get your cloud ready {#before-you-begin}

Sign up for Yandex Cloud and create a [billing account](../../../billing/concepts/billing-account.md):
1. Navigate to the [management console](https://console.yandex.cloud) and log in to Yandex Cloud or create a new account.
1. On the **[Yandex Cloud Billing](https://center.yandex.cloud/billing/accounts)** page, make sure you have a billing account linked and it has the `ACTIVE` or `TRIAL_ACTIVE` [status](../../../billing/concepts/billing-account-statuses.md). If you do not have a billing account, [create one](../../../billing/quickstart/index.md) and [link](../../../billing/operations/pin-cloud.md) a cloud to it.

If you have an active billing account, you can create or select a [folder](../../../resource-manager/concepts/resources-hierarchy.md#folder) for your infrastructure on the [cloud page](https://console.yandex.cloud/cloud).

[Learn more about clouds and folders here](../../../resource-manager/concepts/resources-hierarchy.md).

### Required paid resources {#paid-resources}

The infrastructure support costs for a website include:
* Fee for a continuously running [VM](../../../compute/concepts/vm.md) (see [Yandex Compute Cloud pricing](../../../compute/pricing.md)).
* Fee for using a [public IP address](../../../vpc/concepts/address.md#public-addresses) (see [Yandex Virtual Private Cloud pricing](../../../vpc/pricing.md)).
* Fee for public DNS queries and [DNS zones](../../../dns/concepts/dns-zone.md) if using [Yandex Cloud DNS](../../../dns/index.md) (see [Cloud DNS pricing](../../../dns/pricing.md)).

## Create a cloud network and subnets {#create-network}

All resources created in this tutorial will belong to the same [cloud network](../../../vpc/concepts/network.md).

To create a network and subnets:

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select a folder.
  1. Navigate to **Virtual Private Cloud**.
  1. Click **Create network**.
  1. Enter `web-network` for the network **Name**.
  1. In the **Advanced** field, select **Create subnets**.
  1. Click **Create network**.

{% endlist %}

## Create a security group {#create-security-groups}

[Security groups](../../../application-load-balancer/concepts/application-load-balancer.md#security-groups) contain rules that allow accessing your VMs from the internet. You need to create a security group named `sg-web`.

To create a security group:

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select a folder.
  1. Navigate to **Virtual Private Cloud**.
  1. Open the **Security groups** tab.
  1. Create a security group for your VM:
      1. Click **Create group**.
      1. Enter the group **Name**: `sg-web`.
      1. Select `web-network` for **Network**.
      1. Under **Rules**, create the following rules using the instructions below the table:

          | Traffic<br/>direction | Description | Port range | Protocol | Source /<br/>destination | CIDR blocks |
          | --- | --- | --- | --- | --- | --- |
          | `Outgoing` | `any` | `All` | `Any` | `CIDR` | `0.0.0.0/0` |
          | `Inbound` | `ext-http` | `80` | `TCP` | `CIDR` | `0.0.0.0/0` |
          | `Inbound` | `ext-https` | `443` | `TCP` | `CIDR` | `0.0.0.0/0` |
          | `Inbound` | `ext-ssh` | `22` | `TCP` | `CIDR` | `0.0.0.0/0` |         

          1. Select the **Egress** or **Ingress** tab.
          1. Click **Add rule**.
          1. In the **Port range** field of the window that opens, specify a port or range of ports open for inbound or outbound traffic.
          1. In the **Protocol** field, specify the protocol or leave **Any** to allow traffic over any protocol.
          1. In the **Source** or **Destination** field, select the scope of the rule:
              * **CIDR**: Rule will apply to a range of IP addresses. In the **CIDR blocks** field, specify the CIDR and masks of [subnets](../../../vpc/concepts/network.md#subnet) that traffic will come to or from. To add more CIDRs, click **Add CIDR**.
              * **Security group**: Rule will apply to the current or the selected security group VMs.
          1. Click **Save**. Repeat these steps to create all rules from the table.
      1. Click **Save**.

{% endlist %}

## Create a VM with a pre-installed web server {#create-vm}

{% list tabs group=instructions %}

- Management console {#console}

  1. On the [folder](../../../resource-manager/concepts/resources-hierarchy.md#folder) dashboard in the [management console](https://console.yandex.cloud), click ![image](../../../_assets/console-icons/plus.svg) **Create resource** and select ![image](../../../_assets/console-icons/cpu.svg) `Virtual machine instance`.
  1. Under **Boot disk image**, enter `LAMP` or `LEMP` in the **Product search** field and select the VM image with the components you need: 
      * [LAMP](https://yandex.cloud/en/marketplace/products/yc/lamp) for Linux, Apache, MySQL®, and PHP
      * [LEMP](https://yandex.cloud/en/marketplace/products/yc/lemp) for Linux, Nginx, MySQL®, and PHP

          For static websites, we recommend using LEMP.

  1. Under **Location**, select the [availability zone](../../../overview/concepts/geo-scope.md) to create your VM in. If you are not sure which availability zone you need, leave the default selection.
  1. Under **Computing resources**, navigate to the `Custom` tab and specify the required [platform](../../../compute/concepts/vm-platforms.md), number of vCPUs, and amount of RAM. This minimum configuration is enough for functional website testing:
      * **Platform**: `Intel Ice Lake`.
      * **vCPU**: `2`.
      * **Guaranteed vCPU performance**: `20%`.
      * **RAM**: `1 GB`.
  1. Under **Network settings**:

      * In the **Subnet** field, select `web-network` and the subnet to create your VM in.
      * In the **Public IP address** field, select a static IP address from the list, or leave `Auto` to assign your VM a random external IP address from the Yandex Cloud pool.
  1. Under **Access**, select **SSH key** and specify the VM access credentials:

      * In the **Login** field, enter a username. Do not use `root` or other reserved usernames. For operations requiring root privileges, use the `sudo` command.

      * In the **SSH key** field, select the SSH key saved in your [organization user](../../../organization/concepts/membership.md) profile.

          If there are no SSH keys in your profile or you want to add a new key:
          * Click **Add key**.
          * Enter a name for the SSH key.
          * Upload or paste the contents of the public key file. You need to [create](../../../compute/operations/vm-connect/ssh.md#creating-ssh-keys) a key pair for the SSH connection to a VM yourself.
          * Click **Add**.

          The system will add the SSH key to your organization user profile. If the organization has [disabled](../../../organization/operations/os-login-access.md) the ability for users to add SSH keys to their profiles, the added public SSH key will only be saved in the user profile inside the newly created resource.

  1. Under **General information**, specify the VM name: `lamp-vm` or `lemp-vm`. The naming requirements are as follows:

      * Length: between 3 and 63 characters.
      * It can only contain lowercase Latin letters, numbers, and hyphens.
      * It must start with a letter and cannot end with a hyphen.

  1. Click **Create VM**.

      {% note alert %}

      Once created, the VM gets an IP address and a [host name (FQDN)](../../../compute/concepts/network.md#hostname) for connections. If you selected `No address` in the **Public IP address** field, you will not be able to access the VM from the internet.

      {% endnote %}

  1. Click **Create VM**.

      It may take a few minutes to create your VM. When the VM status changes to `RUNNING`, you can [upload the website files to it](#upload-files).

{% endlist %}

## Upload the website files {#upload-files}

To test the web server, upload the `index.html` file to the VM. You can use a [test file](https://storage.yandexcloud.net/doc-files/index.html.zip). Download and unpack the archive.
1. Find the VM public IP address under **Network** on the VM page in the [management console](https://console.yandex.cloud).
1. [Connect](../../../compute/operations/vm-connect/ssh.md) to the VM via SSH.
1. Grant your user write permissions for the `/var/www/html` directory:

    ```bash
    sudo chown -R "$USER":www-data /var/www/html
    ```

1. Upload the website files to the VM via [SCP](https://en.wikipedia.org/wiki/Secure_copy_protocol).

    {% list tabs group=operating_system %}

    - Linux/macOS {#linux-macos}

      Use the `scp` command line utility:

      ```bash
      scp -r <path_to_directory_with_files> <VM_user_name>@<VM_IP_address>:/var/www/html
      ```

    - Windows {#windows}

      Use [WinSCP](https://winscp.net/eng/download.php) to copy the local file directory to `/var/www/html` on the VM.

    {% endlist %}

## Configure DNS {#configure-dns}

If you have a registered domain name, use the Cloud DNS service to manage the domain.

Below we describe how to configure the DNS for the `example.com` domain name. The `example.com` domain name must be mapped to the VM IP address using [DNS records](../../../dns/concepts/resource-record.md). To do this:

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select a folder.
  1. Navigate to **Compute Cloud**.
  1. Copy the IP address of the VM you created.
  1. On the website of your DNS hosting provider, navigate to the DNS settings.
  1. Create or edit the [A record](../../../dns/concepts/resource-record.md#a) for `example.com` so that it points to the copied IP address:

      ```text
      example.com. A <VM_IP_address>
      ```

  1. Create a [CNAME](../../../dns/concepts/resource-record.md#CNAME) record named `www` with `example.com` as its value.    

      If you use [Yandex Cloud DNS](../../../dns/index.md), follow this tutorial to configure the record:

      {% cut "Configuring DNS records for Cloud DNS" %}

      1. In the [management console](https://console.yandex.cloud), select a folder.
      1. Navigate to **Cloud DNS**.
      1. If you do not have a public [DNS zone](../../../dns/concepts/dns-zone.md), create one:
          1. Click **Create zone**.
          1. Specify the zone **Name**: `example-zone-1`.
          1. In the **Zone** field, enter the website domain name with a trailing dot: `example.com.`.
          1. Select the zone **Type**: `Public`.
          1. Click **Create**.
      1. Create an [A](../../../dns/concepts/resource-record.md#a) record:
          1. In the list of zones, click `example-zone-1`.
          1. Click **Create record**.
          1. Leave the **Name** field empty for the record to match the `example.com` domain name rather than a name with a subdomain, e.g., `www.example.com`.
          1. Select the record **Type**: `A`.
          1. In the **Data** field, paste the copied IP address of the VM.
          1. Click **Create**.
      1. Create a [CNAME](../../../dns/concepts/resource-record.md#cname) record:
         * Select the `example.com` DNS zone from the list.
         * Click **Create record**.
         * Specify the record settings:
           * **Name**: `www`.
           * **Record type**: Select `CNAME`.
           * **TTL** (record time to live): Keep the default value.
           * **Value**: Enter `example.com`.
         * Click **Create**.
      
      {% endcut %}

{% endlist %}

### Delegate the domain name {#delegate-domain}

Delegation is the transfer of authority from the registrar's servers to yours. For a domain, [NS](../../../dns/concepts/resource-record.md#ns) resource records (`ns1.yandexcloud.net` and `ns2.yandexcloud.net`) are created.

To delegate a domain, specify its DNS servers in the registrar's account.

Delegation does not take effect immediately. Internet provider servers normally update records within 24 hours (86,400 seconds). This depends on the TTL value which specifies how long domain records are cached.

You can check domain delegation using [Whois](https://www.reg.com/whois/check_site) or the `dig` utility:

```bash
dig +short NS example.com
```

Result:

```text
ns2.yandexcloud.net.
ns1.yandexcloud.net.
```

## Test the website {#test-site}

To test the site, enter its IP or domain name in your browser:
* `http://<public_IP_of_VM>`
* `http://www.example.com`

## How to delete the resources you created {#clear-out}

To stop paying for the resources you created:

{% list tabs group=instructions %}

- Management console {#console}

  1. [Delete](../../../compute/operations/vm-control/vm-delete.md) `lamp-vm` (`lemp-vm`).
  1. [Delete](../../../vpc/operations/address-delete.md) the static public IP address if you reserved one for your VM.
  1. [Delete](../../../dns/operations/resource-record-delete.md) the DNS records and [delete](../../../dns/operations/zone-delete.md) the DNS zone if you used Cloud DNS.

{% endlist %}

#### Useful links {#see-also}

* [Website based on LAMP or LEMP stack using Terraform](terraform.md).