Hi all, in this video i will show how to install LEMP Stack (Nginx + MariaDB + PHP) on Ubuntu 21.04 desktop/server.

I hope you enjoy!

Links

  1. Ubuntu Download

Steps

#1. Update your System

$ sudo apt update
$ sudo apt upgrade

#2. Install Nginx

$ sudo apt install nginx
$ sudo chown -R www-data:www-data /usr/share/nginx/html
$ sudo systemctl enable --now nginx
$ sudo systemctl status nginx

Point your browser to http://localhost

#3. Install MariaDB

$ sudo apt install mariadb-server mariadb-client
$ sudo systemctl status mariadb
$ sudo mysql_secure_installation

When it asks you to enter MariaDB root password, press Enter key as the root password isn’t set yet. Then enter y to set the root password for MariaDB server.

Next, you can press Enter to answer all remaining questions, which will remove anonymous user, disable remote root login and remove test database. This step is a basic requirement for MariaDB database security. (Notice that Y is capitalized, which means it is the default answer. )

$ sudo mariadb -u root -p

#4. Install PHP

$ sudo apt install php php-fpm \
php-mysql php-gd php-json php-curl
$ sudo systemctl disable --now apache2
$ sudo apt remove apache2
  1. Config Nginx
$ sudo rm /etc/nginx/sites-enabled/default
$ sudo wget -O /etc/nginx/conf.d/default.conf \
https://theduckchannel.github.io/resources/nginx-default.conf 
$ sudo nginx -t
$ sudo systemctl reload nginx

Create /usr/share/nginx/html/info.php with the following content.

<?php phpinfo(); ?>   

Point your browser to http://localhost/info.php

#6. Finish

That´s all.