VK Cloud logo
Updated atDecember 8, 2023   07:45 AM

Installing LAMP on Linux

The LAMP stack includes a Linux operating system, an Apache web server, a MySQL database management system, and a server-side scripting language for processing dynamic PHP content. All this is used to support dynamic websites and web applications.

This instruction will help you deploy an Apache server in the Ubuntu 22.04 operating system in VK Cloud, install PHP, and configure a DNS record for domain name access. MySQL 8.0 Single configuration is used as a DBMS.

Preparatory steps

  1. Register at VK Cloud.

  2. Create network1 network with internet access and a subnet with the address 10.0.0.0/24.

  3. Create VM:

    • name: Ubuntu_22_04_LAMP;
    • flavor: STD3-2-6;
    • operating system: Ubuntu 22.04;
    • network: network1 with subnet 10.0.0.0/24;
    • assign a public IP address. The example will use 211.243.95.137;
    • security groups (firewall settings): default, ssh+www.
  4. Create DB instance:

    • name: MySQL-5864;
    • DBMS: MySQL 8.0;
    • configuration type: Single;
    • network: network1.

    Choose the other parameters at your discretion.

  5. Create DNS zone.

  6. Create an record in the selected zone:

    • record type: A;
    • name: for example, site-lamp.example.vk.cloud;
    • IP address: external VM address 211.243.95.137.
  7. (Optional) Check the name resolution to the IP address using the command nslookup site-lamp.example.vk.cloud. Output upon successful operation:

    1Non-authoritative answer:
    2Name:   site-lamp.example.vk.cloud
    3Address: 211.243.95.137

2. Install Apache and PHP on the VM

  1. Connect to the Ubuntu_22_04_LAMP VM.

  2. Update the packages to the current version and reboot the VM using the commands:

    1sudo apt update && sudo apt upgrade -y
    2sudo reboot
  3. Download the necessary repositories and start the web server:

    1sudo apt install apache2 apache2-utils libapache2-mod-php php8.1 php8.1-cli php8.1-curl php8.1-fpm php8.1-gd php8.1-intl php8.1-mbstring php8.1-mysql php8.1-opcache php8.1-readline php8.1-soap php8.1-xml php8.1-xmlrpc php8.1-zip php-gd -y
    2sudo systemctl enable apache2 --now

3. Check the performance of the web server

  1. On the Ubuntu_22_04_LAMP VM create a file /var/www/html/info.php with content:

    1<?php
    2 phpinfo();
    3?>
  2. In the browser, go to http://site-lamp.example.vk.cloud/info.php.

    A page opens with information about the installed version of PHP.

  3. (Optional) Delete the file /var/www/html/info.php from a web server.

Delete unused resources

Deployed virtual resources are charged. If you don't need them anymore:

  • Delete Ubuntu_22_04_LAMP VM.
  • Delete MySQL-5864 instance.
  • If necessary, delete 211.243.95.137 floating IP address.
  • Delete site-lamp.example.vk.cloud DNS record.