Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Use cases
  • Web service
    • All use cases
    • Static website in Object Storage
    • Website on LAMP or LEMP stack
    • Fault-tolerant website with load balancing from Yandex Network Load Balancer
    • Fault-tolerant website using DNS load balancing
    • Joomla-based website with PostgreSQL
    • WordPress website
    • WordPress website on a MySQL database
    • 1C-Bitrix website
  • Online stores
    • All use cases
    • 1C-Bitrix online store
    • Opencart online store
  • Data archive
    • All use cases
    • Single-node file server
    • Configuring an SFTP server on Centos 7
    • Backup to Object Storage via Acronis Backup
    • Backup to Object Storage via CloudBerry Desktop Backup
    • Backup to Object Storage via Duplicati
    • Backup to Object Storage via Bacula
    • Digitizing archives in Yandex Vision
  • Test environment
    • All use cases
    • Testing applications with GitLab
    • Creating test VMs using GitLab CI
    • High-performance computing on preemptible VMs
  • Infrastructure management
    • All use cases
    • Getting started with Terraform
    • Uploading Terraform states to Object Storage
    • Getting started with Packer
    • VM images building automation using Jenkins
    • Continuous deployment of containerized applications using GitLab
    • Creating a cluster of 1C:Enterprise Linux servers with a Managed Service for PostgreSQL cluster
    • Creating a cluster of 1C:Enterprise Windows servers with MS SQL Server
    • Migrating to Yandex.Cloud using Hystax Acura
    • Emergency recovery in Yandex.Cloud using Hystax Acura
    • Configuring a fault-tolerant architecture in Yandex.Cloud
  • Windows in Yandex.Cloud
    • All use cases
    • Deploying Active Directory
    • Deploying Microsoft Exchange
    • Deploying Remote Desktop Services
    • Deploying an Always On availability group
    • Deploying an Always On availability group with an internal network load balancer
  • Network routing
    • All use cases
    • Routing through a NAT instance
    • Creating a VPN tunnel
    • Installing a Cisco CSR1000v virtual router
    • Installing a Mikrotik CHR virtual router
    • Creating a VPN connection using OpenVPN
  • Data visualization and analytics
    • All use cases
    • Visualizing data from a CSV file
    • Visualizing data from a ClickHouse database
    • Visualizing data from Yandex.Metrica
    • Visualizing data from Yandex.Metrica Logs API
    • Publishing a chart with a map from a CSV file to DataLens Public
    • Visualizing data from AppMetrica
    • Visualizing geodata from a CSV file
  • Internet of things
    • Use cases for the internet of things
    • Status monitoring of geographically distributed devices
    • Monitoring sensor readings and event notifications
  1. Web service
  2. Website on LAMP or LEMP stack

Website on a LAMP or LEMP stack

  • Before you start
    • Required paid resources
  • Create a VM with a pre-installed web server
  • Upload the website files
  • Configure DNS (if you have a domain name)
  • Check that the website is running
  • How to delete created resources

LAMP (Linux, the Apache HTTP Server, MySQL, and PHP) and LEMP (its variation where Apache is replaced with Nginx) are popular sets of components for deploying web applications and dynamic websites.

In this tutorial, you'll learn how to deploy LAMP in the Yandex.Cloud infrastructure: as a result, you'll launch a VM running your site's web server.

To set up a LAMP or LEMP-based website:

  1. Before you start.
  2. Create a VM with a pre-installed web server.
  3. Upload the website files.
  4. Configure DNS.
  5. Check that the website is running.

If you no longer need the website, delete all its resources.

Before you start

Before deploying the server, you need to sign up for Yandex.Cloud and create a billing account:

  1. Go to the management console. Then log in to Yandex.Cloud or sign up if don't already have an account.
  2. On the billing page, make sure you linked a billing account, and it has the ACTIVE or TRIAL_ACTIVE status. If you don't have a billing account, create one.

If you have an active billing account, you can create or select a folder to run your VM in from the Yandex.Cloud page.

Learn more about clouds and folders.

Required paid resources

The cost for maintaining a LAMP server includes:

  • A fee for a continuously running VM (see Yandex Compute Cloud pricing).
  • A fee for using a dynamic or static external IP address (see Yandex Virtual Private Cloud pricing).

Create a VM with a pre-installed web server

To create a VM:

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

  2. In the Name field, enter a name for the VM: lamp-vm or lemp-vm.

    • Length — from 3 to 63 characters.
    • 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.
  3. Select the availability zone to host the VM in. If you don't know which availability zone you need, leave the default.

  4. Under Images from Cloud Marketplace, click Select and choose a VM image with the desired set of components:

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

    For static websites, we recommend using LEMP.

  5. Under Computing resources:

    • Choose a platform for the VM.
    • Specify the necessary number of vCPUs and amount of RAM.

    The minimum configuration is enough for functional website testing:

    • Platform: Intel Cascade Lake.
    • Guaranteed vCPU share: 5%.
    • vCPU: 2.
    • RAM: 1 GB.
  6. In the Network settings section, select the network and subnet to connect the VM to. If you don't have a network or subnet, create them right on the VM creation page.

  7. In the Public address field, leave the Auto value to assign a random external IP address from the Yandex.Cloud pool, or select a static address from the list if you reserved one in advance.

  8. 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 the SSH connection yourself. Learn how to connect to VMs via SSH.

    Alert

    The IP address and host name (FQDN) to connect to the VM are assigned on VM creation. If you selected No address in the Public address field, you won't be able to access the VM from the internet.

  9. 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.

Upload the website files

To test the web server, upload the index.html file to the VM. You can use a test file. Make sure you unzip the archive.

  1. You can learn the IP address of the VM under Network on the VM page in the management console.

  2. Connect to the VM over SSH.

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

    Ubuntu
    CentOS
    $ sudo chown -R "$USER":www-data /var/www/html
    
    $ sudo chown -R "$USER":apache /var/www/html
    
  4. Upload the website files to the VM over SCP:

    Linux/macOS
    Windows

    Use the scp command-line utility:

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

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

Configure DNS (if you have a domain name)

If you want to link a domain name to the deployed server, edit the DNS records for your domain.

The instructions below describe how to configure an external DNS service using reg.ru for the www.example.com and example.com domain names:

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

To configure the external DNS service, do the following:

  1. You can learn the IP address of the VM under Network on the VM page in the management console.
  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 example.com. 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.

Check that the website is running

To test the website, open it in the browser at: http://<VM public IP address>.

You can check the domain name the same way only 15-20 minutes after editing the DNS records.

How to delete created resources

To stop paying for your deployed server, just delete the lamp-vm or lemp-vm virtual machine.

If you reserved a static public IP address specifically for this VM:

  1. Open the Virtual Private Cloud in your folder.
  2. Go to the IP addresses tab.
  3. Find the address you need, click , and select Delete.
In this article:
  • Before you start
  • Required paid resources
  • Create a VM with a pre-installed web server
  • Upload the website files
  • Configure DNS (if you have a domain name)
  • Check that the website is running
  • How to delete created resources
Language
Careers
Privacy policy
Terms of use
© 2021 Yandex.Cloud LLC