LEMP is an acronym that stands for Linux, Nginx(Engine-X), MySQL/MariaDB, PHP/Perl/Python. LEMP is a stack of software used to develop high-performance, dynamic web applications. All the components are open-source.
The components are;
- Linux which is a unix-like operating system that provides the base of the stack.
- Nginx is a powerful proxy server for HTTP,HTTPS, SMTP and POP3 and also functions as a load balancer.
- MySQL/MariaDB is the database engine for storing data.
- PHP/Perl/Python is the Programming language for developing web applications.
You might confuse LEMP with LAMP in which the A is for Apache that is replaced by Nginx. Nginx server is lightweight and uses less memory compared to Apache. Nginx is capable of handling huge traffic of data as compared to Apache making it the best option for Large Companies.
In this guide, I will show you how to install LEMP on KDE Neon / Kubuntu.
Install LEMP Stack on KDE Neon / Kubuntu Linux
Update your package index.
### Kubuntu ###
sudo apt update && sudo apt upgrade -y
1. Install Nginx server on KDE Neon / Kubuntu
Next, install the Nginx web server.
sudo apt install nginx
If prompted for disk space, type Y
to continue.

Allow traffic on port 80 using the following command
sudo ufw allow 'Nginx HTTP'
A sample output will be as follows
Rules updated
Rules updated (v6)
Check status using
sudo ufw status
To enable Nginx to auto-start at boot time, run the following command.
sudo systemctl enable nginx
To start the service run the commands below:
sudo systemctl start nginx
To check status use systemctl command with below command options
sudo systemctl status nginx
Sample output looks like this
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-03-19 10:44:15 EAT; 5min ago
Docs: man:nginx(8)
Main PID: 2620 (nginx)
Tasks: 3 (limit: 4572)
Memory: 3.9M
CGroup: /system.slice/nginx.service
├─2620 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
├─2621 nginx: worker process
└─2622 nginx: worker process
To check version of Nginx installed run;
$ nginx -v
Sample output is as shown below
nginx version: nginx/1.18.0 (Ubuntu)
2. Install and Configure Database server
You can use either MariaDB or MySQL database.
2.1: Install MariaDB on KDE Neon|Kubuntu
To install MariaDB use the following command.
sudo apt install mariadb-server mariadb-client
If prompted for disk space, typey
to continue the installation
Reading package lists... Done
Building dependency tree
Reading state information... Done
Starting pkgProblemResolver with broken count: 0
Starting 2 pkgProblemResolver with broken count: 0
Done
The following packages were automatically installed and are no longer required:
libfwupdplugin1 linux-headers-5.11.0-40-generic linux-headers-5.13.0-27-generic linux-headers-5.4.0-90
linux-headers-5.4.0-90-generic linux-hwe-5.11-headers-5.11.0-40 linux-hwe-5.13-headers-5.13.0-27
linux-image-5.11.0-40-generic linux-image-5.13.0-27-generic linux-image-5.4.0-90-generic
linux-image-5.4.0-96-generic linux-modules-5.11.0-40-generic linux-modules-5.13.0-27-generic
linux-modules-5.4.0-90-generic linux-modules-5.4.0-96-generic linux-modules-extra-5.11.0-40-generic
linux-modules-extra-5.13.0-27-generic linux-modules-extra-5.4.0-90-generic linux-modules-extra-5.4.0-96-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
galera-3 gawk libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libfcgi-perl
libhtml-template-perl libsigsegv2 libterm-readkey-perl mariadb-client-10.3 mariadb-client-core-10.3 mariadb-common
mariadb-server-10.3 mariadb-server-core-10.3
Suggested packages:
gawk-doc libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl libipc-sharedcache-perl mailx
mariadb-test tinyca
The following NEW packages will be installed:
galera-3 gawk libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libfcgi-perl
libhtml-template-perl libsigsegv2 libterm-readkey-perl mariadb-client mariadb-client-10.3 mariadb-client-core-10.3
mariadb-common mariadb-server mariadb-server-10.3 mariadb-server-core-10.3
0 upgraded, 18 newly installed, 0 to remove and 0 not upgraded.
Need to get 19.7 MB of archives.
Check its status. If it is running the status will show as below.
$ systemctl status mariadb
● mariadb.service - MariaDB 10.3.34 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-03-19 10:53:26 EAT; 7s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 4052 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 31 (limit: 4572)
Memory: 63.3M
CGroup: /system.slice/mariadb.service
└─4052 /usr/sbin/mysqld
If it is not running, use the following command to start it.
systemctl start mariadb
To enable auto-start on the service run the commands below:
sudo systemctl enable mariadb
Now run the post-installation script
sudo mysql_secure_installation
Press Enter as the password is not set yet. Then type Y
to set the password

Then press Enter to the other questions to set as default.
Maria-DB uses Unix-socket to authenticate which basically means you can log in to its server using the credentials of your OS. You can use the following command.
sudo mariadb -u root
To exit the server use
exit;
sample output
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 44
Server version: 10.3.34-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> exit;
Bye
To check the version use
$ mariadb --version
mariadb Ver 15.1 Distrib 10.3.34-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
2.2: Install MySQL on KDE Neon|Kubuntu
To install MySQL, use the following command.
sudo apt install mysql-server
sample output
Reading package lists... Done
Building dependency tree
Reading state information... Done
Starting pkgProblemResolver with broken count: 0
Starting 2 pkgProblemResolver with broken count: 0
Done
The following packages were automatically installed and are no longer required:
libfwupdplugin1 linux-headers-5.11.0-40-generic linux-headers-5.13.0-27-generic linux-headers-5.4.0-90
linux-headers-5.4.0-90-generic linux-hwe-5.11-headers-5.11.0-40 linux-hwe-5.13-headers-5.13.0-27
linux-image-5.11.0-40-generic linux-image-5.13.0-27-generic linux-image-5.4.0-90-generic
linux-image-5.4.0-96-generic linux-modules-5.11.0-40-generic linux-modules-5.13.0-27-generic
linux-modules-5.4.0-90-generic linux-modules-5.4.0-96-generic linux-modules-extra-5.11.0-40-generic
linux-modules-extra-5.13.0-27-generic linux-modules-extra-5.4.0-90-generic linux-modules-extra-5.4.0-96-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libcgi-fast-perl libcgi-pm-perl libevent-core-2.1-7 libevent-pthreads-2.1-7 libfcgi-perl libhtml-template-perl
libmecab2 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-8.0 mysql-client-core-8.0 mysql-server-8.0
mysql-server-core-8.0
Suggested packages:
libipc-sharedcache-perl mailx tinyca
The following NEW packages will be installed:
libcgi-fast-perl libcgi-pm-perl libevent-core-2.1-7 libevent-pthreads-2.1-7 libfcgi-perl libhtml-template-perl
libmecab2 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-8.0 mysql-client-core-8.0 mysql-server
mysql-server-8.0 mysql-server-core-8.0
to check if My SQL is running, use the following command
systemctl status mysql
Output from execution:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-03-19 11:35:59 EAT; 1min 32s ago
Main PID: 3047 (mysqld)
Status: "Server is operational"
Tasks: 37 (limit: 4572)
Memory: 357.3M
CGroup: /system.slice/mysql.service
└─3047 /usr/sbin/mysqld
Run the post-installation script
sudo mysql_secure_installation
The process will prompt you to set a password as shown below.

Once you select the level of the password you want to set, Continue to type the new password.

Then check the version using the following command.
$ mysql --version
mysql Ver 8.0.28-0ubuntu0.20.04.3 for Linux on x86_64 ((Ubuntu))
To login to My SQL as root use the following command
sudo mysql
Command execution output;
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.28-0ubuntu0.20.04.3 (Ubuntu)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> exit;
Bye
3. Install PHP on KDE Neon / Kubuntu
Install PHP and other extensions on KDE Neon / Kubuntu.
sudo apt install php-fpm php-mysql
Sample output. Type y
to continue with the installation.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Starting pkgProblemResolver with broken count: 0
Starting 2 pkgProblemResolver with broken count: 0
Done
The following packages were automatically installed and are no longer required:
libfwupdplugin1 linux-headers-5.11.0-40-generic linux-headers-5.13.0-27-generic linux-headers-5.4.0-90
linux-headers-5.4.0-90-generic linux-hwe-5.11-headers-5.11.0-40 linux-hwe-5.13-headers-5.13.0-27
linux-image-5.11.0-40-generic linux-image-5.13.0-27-generic linux-image-5.4.0-90-generic
linux-image-5.4.0-96-generic linux-modules-5.11.0-40-generic linux-modules-5.13.0-27-generic
linux-modules-5.4.0-90-generic linux-modules-5.4.0-96-generic linux-modules-extra-5.11.0-40-generic
linux-modules-extra-5.13.0-27-generic linux-modules-extra-5.4.0-90-generic linux-modules-extra-5.4.0-96-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
php-common php7.4-cli php7.4-common php7.4-fpm php7.4-json php7.4-mysql php7.4-opcache php7.4-readline
Suggested packages:
php-pear
The following NEW packages will be installed:
php-common php-fpm php-mysql php7.4-cli php7.4-common php7.4-fpm php7.4-json php7.4-mysql php7.4-opcache
php7.4-readline
To check the version, use the following command.
$ php --version
PHP 7.4.3 (cli) (built: Mar 2 2022 15:36:52) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
4. Create and Configure Nginx server block
Remove the default configuration file.
sudo rm /etc/nginx/sites-enabled/default
Then create a new file under /etc/nginx as shown below.
sudo nano /etc/nginx/conf.d/default.conf
Copy the following code
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html/;
index index.php index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include snippets/fastcgi-php.conf;
}
# A long browser cache lifetime can speed up repeat visits to your page
location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 360d;
}
# disable access to hidden files
location ~ /\.ht {
access_log off;
log_not_found off;
deny all;
}
}
Save the file and exit. To save the file using Nano press Ctrl+O
then press Enter
then press Ctrl+X
.
Test the configurations
To test the configurations, Use the following command.
sudo nginx -t
Output

Reload if the test is successful.
sudo systemctl reload nginx
5. Test PHP Configurations on Kubuntu / KDE Neon
Use the following command to test if PHP is connected successfully.
sudo nano /usr/share/nginx/html/info.php
Then paste the following code
<?php phpinfo(); ?>
Save the file and exit
Type localhost/info.php on your browser to display the following.

Then remove the PHP file to prevent unauthorized access, You can create the file again later. To remove use the following command
sudo rm /usr/share/nginx/html/info.php
Conclusion
Following this guide, you have successfully installed LEMP on your KDE Neon|Kubuntu system. You have also Created and Configured the Nginx server block and learned how to enable the programs to auto-start on boot.
Similar guides:
- Create Locally Trusted SSL Certificates with mkcert on Windows
- Run Linux Containers with LXC/LXD on KDE Neon|Kubuntu
- Install PhpStorm and WebStorm on KDE Neon|Kubuntu