LEMP is an acronym for Linux (Ubuntu), E Nginx [engine x], MariaDB or MySQL, and PHP Scripting Language. It is a group of open-source software and building blocks for many of the web applications and the majority of the content management systems (CMS) in use today. Many of the popular content management systems being used today are using some combinations of this open-source framework. From WordPress to Drupal to Joomla and many others, they’re all using the LEMP stack to power their applications. If you’re going to be developing any PHP-based applications or websites, then you’re probably going to be using the LEMP stack as well. Below, we’ll show you how to get the stack up and running on Ubuntu Linux. If you’re a student or new user learning Linux, the easiest place to start learning is on Ubuntu Linux. Ubuntu is the modern, open-source Linux operating system for desktops, servers, and other devices. To get started with installing the LEMP stack on Ubuntu Linux, follow the steps below:
How to install Ubuntu Linux
L in LEMP stands for Linux, in this case, Ubuntu. This post chooses Ubuntu Linux because it’s easy to use and basically for beginners. If you’re a new student or new user, Ubuntu Linux is a great place to start with Linux. Your first task to get LEMP configured is a Linux machine. If you haven’t installed Ubuntu before, then read this post to learn how to install it. Once Ubuntu is installed, run the commands below to update it. There are lots of other settings and configurations to apply that apply to Ubuntu, however, the post is only concerned with installing LEMP.
How to install Nginx on Ubuntu Linux
Nginx (engine-x) represents the E in LEMP and is the most popular open-source web server and a key component of the LEMP stack. Nginx is available in Ubuntu repositories. Update the packages index and install Nginx with the following commands. After installing Nginx, the commands below can be used to stop, start and enable the Nginx service always to start up when the server starts. To see if Nginx is installed, open a web browser and browse to the server hostname or IP address. http://localhost If you see the above Nginx welcome page, it means Nginx is installed and functioning.
How to install MariaDB on Ubuntu Linux
The M in LEMP represents MariaDB or MySQL database server. Both MySQL and MariaDB is an open-source, multi-threaded relational database management systems and key components of the LEMP stack. For this post, we’re going to be installing MariaDB instead of MySQL. To install MariaDB, run the commands below. After installing, you can run the commands below to view the MariaDB service status. After running the command above, it should output similar lines as shown below. Both MariaDB and MySQL come with a script that allows you to perform some security operations. Run the commands below to invoke the script and perform some recommended tasks to secure the database. Both MariaDB and MySQL servers come with the root user set to use the auth_socket authentication method by default. The auth_socket plugin authenticates users that connect from the local host through the Unix socket file. This means that you can’t authenticate as a root by providing a password. To log on to MariaDB and MySQL servers as root, simply run the command below. You don’t need a password since it’s using the auth_socket method. To log on to MariaDB, run the commands below. The server console should come up.
How to install PHP on Ubuntu Linux
The P in LEMP stands for PHP. PHP supports many types of web servers, including Nginx, Apache, and a few others. Nginx doesn’t have built-in support for processing PHP files and is not tightly integrated as Apache. To add PHP support for Nginx, you will need to install and use PHP-FPM (FastCGI process manager) to handle the PHP files. If you’re using the Nginx web server, then the commands below are used to install PHP. Because PHP isn’t tightly integrated with Nginx, if you make changes to PHP, you must restart or reload PHP and Nginx separately for the changes to apply. Also, to allow Nginx to read PHP files, you must add these lines to the Nginx server block. Remember to use the version of PHP installed and reference it in the highlighted line shown below. To install the latest versions of PHP that are not available in the Ubuntu repository, run the commands below to install a third-party PPA repository that includes multiple versions of PHP. At the time of this writing, the latest version of PHP is 8.0. After adding the repository above, you can then install another PHP version. That should do it! For more on LEMP, read individual posts on the LEMP components
How to install Ubuntu Linux How to install Nginx How to install MariaDB or MySQL How to install PHP
Conclusion: This post showed you how to install the LEMP stack on Ubuntu Linux. If you find any error above or have something to add, please use the comment form below.