If you want to set up a local web-server and look for some tips, this article is for you. Here are instructions for setting up a web server (LAMP = Linux + Apache + MySql + PHP) on OS Ubuntu 20.04, in connection with:

Apache 2
Mysql Sever 8

Disclaimer: Use this instruction only to configure development or testing environments. Do not use it to configure production servers.

To start, go to the CLI (command-line user interface). You can open it with Ctrl + Alt + T combination.

Enter superuser mode (root or sudo user). Run the following command:

sudo su

and enter the password to your account, if required.

Take the following steps to install the webserver:

1. Update the available package information. Run this command:

sudo apt update

* In the examples, the commands that must be executed by the superuser begin with the word sudo. You do not have to use sudo while in superuser mode.

2. Install the Apache 2 webserver.

sudo apt install apache2

3. Install the database server MySql.

sudo apt install mysql-server

After the MySQL server database was installed, run the following command:

mysql -uroot

Also, enter these commands, one by one, to create a new user: 

CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY '<New-Password-Here>';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;

4. Install php7.4 and all necessary PHP libraries to work with Apache 2 and Magento 2.

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

sudo apt install php7.4 libapache2-mod-php7.4 php7.4-curl php7.4-intl php7.4-zip php7.4-soap php7.4-xml php7.3-mysqli php7.4-gd php7.4-mbstring php7.4-bcmath php7.4-common php7.4-xml php7.4-mysqli

5. Enable the apache mod to work with php7 and restart the webserver.

sudo a2enmod php7.4
sudo a2enmod rewrite
sudo service apache2 restart

Follow the link and check if your local web server is working: (alternative http://localhost/). If everything is correct, the following page will open:

Перевірки роботи mysql сервера

6. Change the user based on which the web server will run.

For this edit the following file /etc/apache2/envvars.

sudo gedit /etc/apache2/envvars 

find these strings there:

export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data

and replace them with:

export APACHE_RUN_USER=your_user
export APACHE_RUN_GROUP=your_group

where your_user — the name of your operating system user, and your_group — group this user belongs to. Usually, the names of the user and the group are the same.

Save the file and reload the web server.

sudo service apache2 restart

7. Change the owner of the web directory.

A web directory is a folder where your web application, such as Magento 2, is located. The goal is to give your user complete control over that folder. Run the following command:

chown -R your_user:your_group /var/www/html

8. Increase the memory limit (RAM) that is allowed for PHP.

By default, this value is 128 MB, which is insufficient to work with Magento 2.

Open the /etc/php/7.3/apache2/php.ini file for editing:

sudo gedit /etc/php/7.4/apache2/php.ini

find the following string

memory_limit = 128M

change it to

memory_limit = 1024M

and set the minimum value 3600

max_execution_time = 3600

for this parameter

max_execution_time =

save changes and reload the web server once again.

sudo service apache2 restart

9. Change the virtual host settings.

Edit this file


and add the following code to the middle of the VirtualHost node:

<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted

Save changes and reload the web server

sudo service apache2 restart

10. To control MySql databases, for example, to create new databases (databases) we recommend to install phpMyAdmin.