Website on LAMP or LEMP stack
To configure a static website or dynamic website in PHP:
Before you start
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. To do this, click the Virtual Private Cloud tile on the folder page. If the list contains a network, click on its name to see the list of subnets. If there aren't any networks or subnets, create them.
1. Create a VM with a pre-installed web server
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 length of the name 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:
- Choose the platform.
- Specify the required amount of vCPUs and RAM.
The minimum configuration is enough for functional testing:
- Platform: Intel Cascade Lake.
- Guaranteed vCPU share: 5%.
- vCPU: 2.
- 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 created, it is assigned an IP address and hostname (FQDN). This data can be used for SSH access.
2. Upload the website files
Go to the VM page of the management console. In the Network section, 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 access to the directory
$ sudo chown -R "$USER":www-data /var/www/html
$ sudo chown -R "$USER":apache /var/www/html
Upload the website files to the VM over 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.
3. Configure 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 reg.ru for the
example.com domain names:
- An A record 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 the external DNS service, do the following:
- Go to the VM page of the management console. In the Network section, 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.