LAMP is an acronym for a set (complex) of server software widely used on the World Wide Web. LAMP is named after the first letters of its constituent components:

  • Linux is the operating system on which the web application infrastructure is deployed;

  • Apache - the web server;

  • MariaDB / MySQL - used to work with databases ;

  • PHP - programming language used to create web applications.

First let's update the information about the packages in the repositories:

# apt-get update

Now you can install the software.

Installing Apache

To do this at the command line, type:

# apt-get install apache2

Installing MySQL

Enter the command:

# apt-get install mysql-server mysql-client

During the installation you will be asked for the root password for the mysql-server, it is better to set a more difficult password to avoid hacking.

Installing PHP*

You can use the command:

# apt-get install php5 php5-mysql

This will also install the base set of PHP extensions and the PHP module for Apache - libapache2-mod-php5

Add site

If you plan to host more than one site, you will need to create VirtualHost for all sites in the Apache configuration files.

On Debian, VirtualHosts are connected from a separate directory /etc/apache2/sites-enabled/

It is also best to create a separate file for a separate domain and name it with the name of the domain.

Creating a configuration file for a domain

To create a file run the command

touch /etc/apache2/sites-enabled/mysite.com  

Open it for editing in a text editor:

<VirtualHost 111.111.111.111:80 >  
       ServerName mysite.com
       ServerAlias www.mysite.com
       DocumentRoot /var/www/sites/mysite.com
       CustomLog /var/www/httpd-logs/mysite.com.access.log combined
       ErrorLog /var/www/httpd-logs/mysite.com.error.log
       AddType application/x-httpd-php .php
</VirtualHost>  
  • Instead of 111.111.111.111.111 - use server IP,

  • Instead of mysite.com - domain name.

Creating a database in MySQL

You need to create a database for the site.

mysql -u root -p  

Create a database and give user rights to it:

create database db;  
grant all privileges on db.* to 'user'@'localhost' identified by 'password';  
  • db - base name,

  • user - name of the user to be created,

  • password - password.

Creation of the site directory and installation of CMS*

Create directories for the site and logs, as well as log files themselves:

mkdir /var/www/sites/  
mkdir /var/www/sites/mysite.com  
mkdir /var/www/httpd-logs  
touch /var/www/httpd-logs/mysite.com.access.log  
touch /var/www/httpd-logs/mysite.com.error.log  

To install the CMS, go to the domain directory and download the distribution of the desired CMS:

cd /var/www/sites/mysite.com  
wget https://ru.wordpress.org/latest-ru_RU.zip  

Then unzip the downloaded archive:

unzip wordpress-4.9.4-en_RU.zip  

Now, if your DNS records lead correctly to your server, you can go to the site to continue the installation by domain, and if not, then by IP address.

Updated Feb. 11, 2019