Best Way How to Install a LEMP Server on Rocky Linux

How to install Lemp on Rocky Linux?

Best Way How to Install a LEMP Server on Rocky Linux

How do I set up a Lemp server?- Install LEMP Server on Rocky Linux

How to install Lemp on Rocky Linux, I’m going to show you how to install a LEMP server on rocky Linux LEMP is an acronym that stands for Linux Nginx MySQL or maria database and PHP and this is a server stack that allows you to run a website or a web application on top of it.

So if that’s something you want to learn how to do let’s go ahead and get on into it I will assume that you have rocky Linux installed if you don’t I have some credits down below that you can get started with it for free on a VPS and that is what I have here on my screen I’m logged into my vulture VPS and let’s get started.

Let me prove to you that I am actually indeed running rocky Linux so I can look at the os-release file under the etc directory and I am indeed running rocky Linux version 8.5 so as always good practice before we do anything any major installs on the system let’s do an update or an upgrade and um the equivalent for you know.

If you’re on uh red hat or centos you use a yum package manager if you’re on Ubuntu or Debian use apt or apt-get the equivalent for that on rocky Linux is called DNF and in order to update our system upgrader system we can do DNF upgrade now, I did that a little bit before.

So all my packages are up to date but this can take anywhere from you know a couple of seconds to a few minutes 10 15 minutes to update all your packages you know depending on your hardware and your bandwidth and all that stuff so go ahead and do that first but then we can go ahead and install the lamp server.

So we already have rocky Linux that takes care of the l e is Nginx it’s spelt with an n but they say e for engine and because it sounds like an e so let’s go ahead and install Nginx with DNF so DNF install Nginx and this is a small package 14 megabytes.

So we’ll go ahead and do that and skip forward through this okay and just a few moments later we have Nginx installed let’s start that up with the system ctl start nginx and that’s going to allow Nginx to run um right now so let’s verify that that is the case system ctl status nginx and it is indeed active and running that’s good.

Also Read: 7 Best Ways How To Create VNC Remote Network On Mac

LEMP Server on Rocky Linux – Nginx Automatic Start

Best Way How to Install a LEMP Server on Rocky Linux

Um if we want Nginx to automatically start when our server reboots or starts up we can do system ctl enable Nginx and that’ll go ahead and take care of setting up that service okay at this point we do have Nginx running let’s verify that with a web browser so I’m going to open up google chrome and get my IP address what was my IP address right here.

So let me type that in 174.1 oops 138.61.103 hit enter and we see the default landing page for Nginx on rocky Linux so great progress so far we have a website and as it says here these the files that are serving this page are located at user share Nginx HTML.

So let’s check that out on our uh terminal window let’s go to that directory and in here we have an index file a logo two uh images and then a 404 and a five-oh x dot HTML file these are the error pages and this is the file that we’re looking at so let me just prove that let’s look at index.html and we don’t have vim on this.

Um feel free to use whatever text editor I prefer vim there’s a light version of that called vi which they should have they do um let’s see let’s search for has been these words right here has been and there it is so HTTP server after it has been installed and let’s just modify that to prove that we’re looking at the same thing yo.

And if we refresh this page back here and that shows up so very good this is the root of our website now uh so lamp Linux Nginx MySQL Marita database or one of those two or PHP and PHP um what should we do next let’s go ahead and look at PHP um let me let’s see what version of PHP.

Also Read: The Story Of How To Run Windows In The Cloud (seriously Cheap VPS Hosting) 2022

LEMP Server on Rocky Linux – PHP and DNF Module list

If any we have installed by default PHP dash PHP is not installed so let’s go ahead and check out what we have as options for PHP to install so we can do dnf module list PHP and that’s going to tell us what we can enable and install so they have PHP 7.2 3 and 4 and it looks like 7.2 is the default but let’s say I want 7.4 to be the version of PHP that I want to use.

So we can do dnf module enable PHP colon 7.4 hits to enter and now that we have enabled PHP 7.4 well actually it’s asking us if this is okay so type yes hit enter okay so that’s complete now we can install PHP 7.4 with DNF so dnf install PHP hit enter and I just want to show you what this is actually going to install first not only is it going to install PHP.

But it’s also going to install PHP fpm which is necessary for allowing nginx to talk to PHP it’s like a module that acts as an intermediary between the two and a whole bunch of other ones including PHP common so that’s good just review that hit y and then enter to download and install those packages and we will again skip forward through this alright.

So we have PHP let’s verify that with PHP-v and we are indeed running PHP version 7.4 now there’s uh in order to have PHP play with Nginx correctly let’s edit this file at etc PHP dash fpm d and then www. conf and by default, it’s kind of assuming that you’re going to use apache but we’re not.

Let me what are we’re looking for group and user right here um user apache group apache we need to change that to Nginx so go ahead and do that and save that file now since we made a change to that file the PHP fpm file let’s do a system ctl start PHP dash fpm.

Also Read: Full virtualization vs Paravirtualization in cloud computing – 2022

LEMP Server on Rocky Linux – System and MCT Status PHP-FPM

Best Way How to Install a LEMP Server on Rocky Linux

I’m not sure if that was already started we probably could have checked but anyway system Syst MCT status PHP-fpm and oh I cannot spell today system s-y-s an extra y in there so the status uh PHP FM is active and running let’s same thing as before if we wanted to start up automatically.

When our server reboots we can do system ctl enable PHP dash fpm and I think for good measure at this point let’s just do a system ctl restart Nginx just to make sure I’m not sure if that’s necessary but just to make sure that we’re all good so before and here we were working with an HTML file let’s test out a PHP file.

Let’s just get rid of this index HTML file and make a new file called index.php and you can do something very there’s a lot of cool tricks that you can do with PHP but we’re just going to do something very simple some dynamic right so PHP gives us the ability to make dynamic HTML pages.

We’re going to echo inside of the PHP block the time is and then hours minutes seconds so we’ll save that and that that’ll execute on the server generate the HTML send it over to the client so if we go back here and we don’t we shouldn’t have to explicitly go to index.php.

But let’s just do that index.php hit enter and yep the time is 300 3 15 54 pm and if you go refresh it the time will update so we have PHP dynamically generating pages and let’s see if that matches up with the server time and it does for UTC okay so that takes care of Linux Nginx PHP now let’s do the database MySQL we’re going to do maria database in this case.

Also Read: What is full virtualization in cloud computing – 2022

LEMP Server on Rocky Linux – Install DNF Install MariaDB Server

Best Way How to Install a LEMP Server on Rocky Linux

So we can do that with DNF install maria m-a-r-i-a-d-b dash server hit enter and you should be used to it that at this point it’s going to install download 31 megs install 156 megs so y hit enter and we will fast forward through this okay that has been downloaded and installed you guys know the routine system ctl start maria DB hit enter system ctl status maria DB.

That is active and running and then system ctl enable maria DB and again that’s going to allow this service to start up when the system starts up so a good practice is to do the secure installation step after you install so we can do that with my SQL underscore secure underscore installation hit enter.

Oh, they don’t have that MySQL secure installation um okay forget that I said that okay so we won’t do too much with it in this tutorial but I just want to show you how you can access the MySQL command line um and you can do that with my sequel I think let’s just show you my sequel without any credentials that works.

Also Read: Understand Ford Vs. GM: Old Rivals Battle For Share Of The EV Truck Market Before You Regret 2022

LEMP Server on Rocky Linux – SQL Dash User Root

Best Way How to Install a LEMP Server on Rocky Linux

Um if this is a fresh install but sometimes let’s exit out of here sometimes you might have to do my SQL dash you user root dash p and then provide your password but we don’t have that password information at this point so we can just use our root user to log in directly in here a quick overview of MySQL you can look at the databases with show databases semicolon.

And we have just three databases where you can create a database you can uh let’s let we won’t do that but let’s look at the tables inside of my SQL so use my SQL to look at that database only and then show the tables associated with my sequel and these are just the default tables that are uh that come packaged with my sequel.

Also Read: 15 Doubts You Should Clarify About The Crypto Winter Is Coming.

Similar Posts