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:
- Go to the Yandex.Cloud management console and select the folder where you want to perform the operations.
- 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:
On the folder page of the management console, click Create resource and select Virtual machine.
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.
Select the availability zone to locate the VM in.
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.
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.
In the Network settings section, select the subnet to connect the VM to when creating it.
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-keygenutilities on Linux and macOS or PuTTygen on Windows.
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.
Uploading website files
In the Network section on the VM page of the management console, find the VM's public IP address.
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.
Grant your user write rights to the directory
$ sudo setfacl -m u:<your user's name>:w /var/www/html
Upload the website files to the VM via the SCP.Linux/macOSWindows
$ 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/htmldirectory on the VM.
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 reg.ru for
example.com domain names:
- A record of the A type allows you to map the
example.comdomain name to its IP address.
- A CNAME (Canonical Name) record for
wwwallows you to access your website via
To configure an external DNS server, do the following:
- In the Network section on the VM page of the management console, find the VM's public IP address.
- 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.
- Follow the Zone management link in the Domain management section.
- Create or edit an A record:
- IP Address — your VM's public IP address.
@(points to the main domain).
- Create a CNAME record with the following field values:
- Canonical name:
example.com.domain with a dot at the end.
- Wait 15-20 minutes for DNS record changes to take effect. The waiting time may differ for your DNS service.