How to Install LEMP Stack on Ubuntu 20.04
The LEMP stack is one of the most popular kits as the basis for a web site. It consists of a Linux server, Nginx web server, MySQL database management systems and PHP. We're going to take a look at the process of installing a LEMP stack in Ubuntu 20.04. All commands must be run as root or add sudo before them.
In the Serverspace you can create a server with already installed app "LEMP".
Installing Nginx
First, let's update the package manager cache and install Nginx.
apt update
apt install nginxIf the firewall is enabled, you need to allow access to the server on port 80:
ufw allow in "Nginx HTTP"Output:
Rules updated
Rules updated (v6)You can now check if the Nginx web server is running by entering your server's public IP address into your browser's address bar. You will see the following page:

Installing MySQL
To install MySQL server enter:
apt install mysql-serverOnce installed, run the script and follow the instructions to configure the recommended MySQL security settings. The most secure setting will be achieved with affirmative answers and the strictest password complexity check.
mysql_secure_installationInstalling PHP
Install the following packages to get PHP running on the server.
apt install php-fpm php-mysqlConfiguring Nginx for PHP Processing
In this tutorial, we'll show you how to configure PHP processing using the default virtual host as an example. When configuring Nginx to work with multiple domain names, this setting will also apply. Nginx virtual host basic configuration guide.
Open the default virtual host configuration file.
nano /etc/nginx/sites-available/defaultAdd the next code to the end of the server section:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
Save and close the file and check the configuration for errors:
nginx -tRestart Nginx:
systemctl restart nginxTesting PHP on Nginx Server
We will now create a .php file on our server and check if PHP is running. Create a file:
nano /var/www/html/info.phpPaste the following content here:
<!--?php phpinfo(); ?-->Now enter your server's public IP address into your browser's address bar with /info.php at the end:
http://server-public-ip/info.phpIf you see the following content, PHP works fine with Nginx.

700
300
700
300
700
300