In this guide, we are going to learn how to install LEMP (Nginx,MariaDB,PHP7.2) Stack on Fedora 28 / Fedora 29. As you already know, LEMP Stack is an acronym that stands for Linux Operating system, which is of course the system on which your are going to do installations on, Nginx, commonly pronounced as Engine-x, MariaDB/MySQL, which is a relational database management systems and PHP which is a server-side dynamic web scripting language.
How to Install LEMP (Nginx,MariaDB,PHP7.2) Stack on Fedora 28 / Fedora 29
Install Nginx Web Server on Fedora
Before you can proceed, it is a good ideas to update your system.
Once your update is done, install Nginx. Nginx is available on Fedora default repositories and can just be install using the package manager as shown below.
dnf install nginx -y
Once the installation is done, start and enable Nginx to run on system reboot.
systemctl start nginx systemctl enable nginx
You can now test your web server after installation. If firewall is running, you need to allow Nginx through it.
firewall-cmd --add-service=http --permanent firewall-cmd --reload
Navigate to your browser and enter your server’s hostname or IP address in order to test if Nginx is actually working. If all is well, you should be able to see such a page as shown below;
Installing MariaDB on Fedora
MariaDB is an opensource relational database management system that has been forked from the famous MySQL. It is available by default on Fedora repositories and can be installed as shown below.
sudo dnf install mariadb-server -y
Start and enable MariaDB to run on system boot.
systemctl start mariadb systemctl enable mariadb
MariaDB comes bundled with a security script call
mysql_secure_installation that is used to perform basic database security by setting up root password, removing anonymous users, test databases and disabling database remote login. Press Enter to accept yes.
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): ENTER OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] y New password: STRONGPASSWORD Re-enter new password: STRONGPASSWORD Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
To verify that all is well, try to login to MariaDB as a root user.
mysql -u root -p
Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 16 Server version: 10.3.10-MariaDB MariaDB Server 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)]>
Well, seems we are in business! Proceed to Install PHP.
Installing PHP on Fedora
Well, we require PHP in order to generate dynamic web content. Installation of PHP and other requires PHP extensions can be done as shown below;
sudo dnf install php php-fpm php-mysqlnd php-gd php-mcrypt php-mbstring
Your LEMP stack setup is now done. Before you can conclude that all is well, create a PHP test page to verify that it is actually working.
Create a test page,
/usr/share/nginx/html/info.php with the following contents.
<?php phpinfo(); ?>
Navigate to the browser and enter your PHP info page URL in the format shown below. Note that this will take you to a web page where you can see various PHP information. See the screenshot below.
Congratulations, your LEMP stack is now setup and is fully functioning. You might have to remove the info.php file to avoid exposing your server information to the internet crooks.
You can also check our previous similar articles by following the links below.