How to build a LAMP Stack on CentOS 7.6.

How to Build a LAMP Stack on CentOS 7.6

Introduction

Hello everybody, welcome to my post on how to build a LAMP Stack on CentOS 7.6. This is one of my most favorite things to do and is fairly easy. I promise once you follow this you’ll have a web server running in no time. I have also recorded a video that you can view.

Getting Started

Alright let’s get started! First thing you’ll need is a VPS of some kind or a Dedicated Server. Now I personally use Digital Ocean for my VPS Machines when I make these. Once you have a VPS created then you’ll need to do the following.

SSH

In order to SSH into your server you’ll need a client of some sort. You can use PuTTY or if you have another SSH client feel free to use that. Once you have it ready you need to type in the following command.

ssh root@yourserverip

Once you do that a prompt will ask for your password and you’ll enter it. Then hit save/accept and then you’ll be asked to enter your password again and then change your password to something else and then you’ll confirm your new password.

Update/Upgrade

Once you’ve entered your server you’ll now need to do an update/upgrade. To do this you’ll need to use the following commands:

yum update -y
yum upgrade -y

Once you’ve done this your server will update/upgrade (if any are needed).

Install Apache

In order for you to have a working LAMP Stack you need the base, APACHE! This is very easy to install and get running. First install Apache:

yum install httpd -y
systemctl start httpd.service

If that worked then when you go to your Domain/IP then you’ll see a testing 123.. page. This means everything is working the way it should be so now we need to make sure that APACHE restarts when the server restarts:

systemctl enable httpd.service

Install MariaDB

After APACHE is install and running now we’ll need to install MariaDB.

yum install mariadb-server mariadb -y
systemctl start mariadb

Now we need to do the secure installation

mysql_secure_installation

Then there will be some options you’ll need to go through

Enter current password for root (enter for none): Hit Enter

Set root password? [Y/n]: y

New password: Enter a password

Re-enter new password: Re-enter your password

Remove anonymous users? [Y/n]: y

Disallow root login remotely? [Y/n]: y

Remove test database and access to it? [Y/n]: y

Reload privilege tables now? [Y/n]: y

 

Install PHP

Next we’ll need to install PHP. 

yum install php php-mysql -y
systemctl restart httpd.service

Then we’ll need to create a test file to make sure PHP is running

nano /var/www/html/info.php
in the editor type in <?php phpinfo(); ?>
ctrl + x
y and hit enter

When done you can go to your domain or ip address /info.php

 

Share this post

Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on tumblr
Share on telegram
Share on email
Share on print