In this tutorial we will show you how to install LEMP Stack on CentOS 8. For those of you who didn’t know, LEMP stands for Linux, Nginx (pronounced engine X), MariaDB/MySQL and PHP, all of which are open source. It is the most common software stack that powers dynamic websites and web applications. Linux is the operating system; Nginx is the web server; MariaDB/MySQL is the database server and PHP is the server-side scripting language responsible for generating dynamic web pages.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation LEMP Stack on CentOS 8 server.
Install LEMP Stack on CentOS 8
Step 1. First let’s start by ensuring your system is up-to-date.
Step 2. Installing Nginx on CentOS 8.
Nginx is a high performance web server and very popular these days, The first step is to install Nginx. So open a terminal session or connect to your server using SSH:
Once the installation is done, start and enable Nginx to run on system boot:
The next step is to open the ports in the Firewall so that we can use Nginx:
You can verify that Nginx is really running by opening your favorite web browser and entering the URL http://your-server’s-address, if it is installed, then you will see this:
Step 3. Installing MariaDB Database Server.
MariaDB is a pretty good database manager. It is a MySQL fork and therefore compatible with it. It is one of the open-source values. Install MariaDB on CentOS 8 with the command:
Once you have installed MariaDB server, start and enable it to run on system boot:
By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. you should read and below each steps carefully which will set root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MySQL:
Install PHP and related modules using the following command:
If you need other PHP extensions for your web applications, simply install by running:
### Replacing EXTENSION with your respective PHP module ###
Then, start and enable PHP-FPM to run on boot:
You can test PHP to confirm that is working as required as well check the version and installed modules using the simple PHP info script:
Save and close the file. If you installed LEMP stack on CentOS 8 server, type in 127.0.0.1/info.php or localhost/info.php in the browser address bar. You should see your server’s PHP information. This means PHP scripts can run properly with Nginx web server.
Congratulation’s! You have successfully install LEMP. Thanks for using this tutorial for install LEMP Stack on CentOS 8 system. For additional help or useful information, we recommend you to check the official LEMP website.