Website on LAMP or LEMP stack

To configure a static website or dynamic website on your PHP:

Creating a VM with a pre-installed web server

Before creating a VM:

  1. Go to the Yandex.Cloud management console and select the folder where you want to perform the operations.
  2. Make sure the selected folder has a network with a subnet that the VM can be connected to. For that, on the folder page, click the tile Yandex Virtual Private Cloud. If the list contains a network, click on its name to see the list of subnets. If there is neither network nor subnet, create them.

To create a VM:

  1. On the folder page of the management console, click Create resource and select Virtual machine.

  2. In the Name field, enter the VM name.

    The name must be unique within the folder. The name may contain lowercase Latin letters, numbers, and hyphens. The first character must be a letter. The last character can't be a hyphen. The maximum name length is 63 characters.

  3. Select the availability zone to locate the VM in.

  4. Select a public image:

    • LEMP for Linux, nginx, MySQL, and PHP.
    • LAMP for Linux, Apache, MySQL, and PHP

    For static websites, we recommend using LEMP.

  5. In the Computing resources section, select the type of core usage (partial or full) and specify the necessary number of vCPUs and amount of RAM.

    The minimum configuration is enough for functional testing:

    • Guaranteed vCPU share: 5%.
    • vCPU: 1.
    • RAM: 1 GB.
  6. In the Network settings section, select the subnet to connect the VM to when creating it.

  7. Specify data required for accessing the VM.

    • Enter the username in the Login field.
    • In the SSH key field, paste the contents of the public key file. You need to create a key pair for SSH connection yourself. To generate keys, use third-party tools, such as ssh-keygen utilities on Linux and macOS or PuTTygen on Windows.
  8. Click Create VM.

Creating the VM may take several minutes. When the VM status changes to RUNNING, you can upload the website files to it.

When a VM is being created, it is assigned an IP address and hostname (FQDN). This data can be used for SSH access.

See also

Uploading website files

  1. In the Network section on the VM page of the management console, find the VM's public IP address.

  2. Connect to the VM via SSH. You can use the ssh tool on Linux and macOS and PuTTy for Windows.

    The recommended authentication method when connecting over SSH is using a key pair. Don't forget to set up the created key pair: the private key must match the public key sent to the VM.

  3. Grant your user write rights to the directory /var/www/html:

    $ sudo setfacl -m u:<your user's name>:w /var/www/html
  4. Upload the website files to the VM via the SCP.

    Use the scp command-line utility:

    $ scp -r <path to the file directory> <your user's name>@<VM's IP address>:/var/www/html

    Use the WinSCP program to copy the local file directory to the /var/www/html directory on the VM.

Configuring DNS

The domain name that you want to use for your website must be associated with the created VM.

The instructions below describe how to configure an external DNS service using as an example for and domain names:

  • A record of the A type allows you to map the domain name to its IP address.
  • A CNAME (Canonical Name) record for www allows you to access your website via

To configure an external DNS server, do the following:

  1. In the Network section on the VM page of the management console, find the VM's public IP address.
  2. Log in to the control panel of the external DNS service. Go to the list of your domains and click on the required domain name.
  3. Follow the Zone management link in the Domain management section.
  4. Create or edit an A record:
    • IP Address — your VM's public IP address.
    • Subdomain: @ (points to the main domain).
  5. Create a CNAME record with the following field values:
    • Subdomain: www.
    • Canonical name: @ or the domain with a dot at the end.
  6. Wait 15-20 minutes for DNS record changes to take effect. The waiting time may differ for your DNS service.