LAMP STACK Project Implementation

LAMP STACK PROJECT IMPLEMENTATION

The main aim of this project is to explain the DevOps concepts and processes using a LAMP web stack. Some developers use this set of frameworks and tools to develop software products. We would be carrying out this project on the AWS platform

LAMP is an acronym for sets of technology used to develop a technical software product.

Linux

Apache

MySQL

PHP

Please note : (P could also stand for Python or Perl )

The Apache server used is the apache2 version

The pre-requisite for the projects is the following.

1) Fundamental Knowledge of Installing and downloading software
2) Basic Understanding of Linux Commands
3) AWS account login with EC2 instance
4) Internet connection

IMPLEMENTATION STEPS:

i) Ensure you login with your details to your AWS console via the
https://aws.amazon.com
ii) Click on the EC2 link to create instances.

image

iii)Click on the launch instance dropdown button and select launch instance.

image

image

iv)Fill in all relevant details to the lamp project such as :

Type in the name and additional tag to the project (lamp) . Selected ubuntu from the quick start option . Also note that the Amazon machine image selection varies from user to user

Select Ubuntu server 22.04 LTS (HVM),SSD Volume Type (Free Tier )

image

v)The instance type selected in the configuration is the t2 micro-free tier.

Click on the “Create new key pair” link.

Ensure the Checkbox remains on the “Create security group”.

image

vi)Typed in the key pair name, chose the default key pair type and private key file format (rsa and .pem) and clicked the “Create key pair button”

image

vii)The .pem file was downloaded successfully.

image

viii)I have deliberately chosen default settings to allow SSH traffic from anywhere as well as the storage volume given by AWS. Then proceed to launch our instance successfully.

image

ix)Instance successfully launched.

image

x)Select checkboxes to view more details about the instance created.

image

The public IP address shown on the screenshot should be
copied as we would be using it on the console.
Open git bash on visual studio code or whichever console is
convenient to use.
We are using git bash here with Visual Studio Code

image

Type YES ,to connect

image

You have successful connected to the EC2 instance launched
on AWS via ssh
Type clear to have a clear console and proceed to updating the
lists of packages in the package manager

image

Then we run apache2 installation and click yes to complete
installation

image

We have to verify that Apache is running in our Operating System.

image

To proceed by launching the web server in the AWS Cloud, we need to navigate back to the security group on the platform to add a new rule for TCP port 80 which is the default for web browsers. Once done we can access the web page on the internet.

Click on the security button.

image

And click the security group link

image

Click on “Edit inbound rules “ in order to add a new rule for port 80

image

Add a new rule

image

Type in the port range and click “Anywhere ipv4”

image

Click the “Save rules” Button

image

Inbound rule successfully modified.

image

Open any browser of your choice and access the URL http://34.201.134.152:

image

Apache2 default page successfully displayed.

From the LAMP stack, we have implemented with Linux and got Apache ready.

The next step would be to get MySQL installed.

MYSQL INSTALLATION

Now that our web server is running, we need a relational database used within the PHP environment hence we installed MySQL server

Type “Y” and enter.

image

When installation is finished, Log in to connect to the MySQL server as the administrator user root so that you can have access to the sudo command.

image

It is important to set up a password for the user root using mysql_native_password as a default authentication method. Please note the password not revealed for security purposes Exit MySQL

image

Interactive script is started, and all modifications are answered with a Y/N response

Root user password was set Validate password: No
Change password: No
Remove anonymous user: No

image

Disallow remote login: No

Remove the test database and access it: No

Reload privilege tables: Yes.

image

Verify login details to ensure all details were inputted correctly and exiting MySQL

image

MySQL server was correctly installed and secured.

Next, we proceed to the PHP installation which is the final component of the LAMP STACK

PHP INSTALLATION

PHP is the component that processes the codes to display dynamic content to the end user. Hence, we would need to install 3 packages namely :

1)PHP package 2) libapache2-mod-php 3) php-mysql.

image

Installation continues.

image

After installing, we checked the PHP version.

image

At this point, the LAMP STACK implementation is completed and fully operational

We need to test our setup with a PHP script and this needs a proper APACHE virtual host to keep your website files and folder. Multiple websites can be hosted on a single machine and the users would not notice

CREATING AN APACHE VIRTUAL HOST FOR OUR WEBSITE TO USE.

image

The next step, making a directory for the site directory, running below

Then proceed to edit a new site directory to input the virtual host information.

image

Put the edited file in an insert mode by typing “i” without quotes and add the config files, press ESC , save and exit with “ :wq” command

image

Next, check the content of the sites-available directory and you will see 3 configuration files on here.

image

With these configuration files, we would need to DISABLE the 000-default config file and ENABLE the new directory we created using the following command

image

After enabling and disabling is done successfully, we would verify that there are no syntax errors with the command below

image

Then we proceed by reloading the Apache server to make these changes take effect.

image

The new website is now active but the projectlamp has empty file. We create an index.html file in that location so that we can test whether our virtual host is performing as expected.

image

Proceed to the browser and open the previous website using the ip address

image

Echo successfully displayed but this is just to test the website.

Type “clear” command to clear the screen.

ENABLE PHP ON THE WEBSITE

We would need to set up an index.php file to replace the index.html file from the document root as it needs to override the default settings. This is a very useful maintenance page for PHP application

image

Files are edited correctly while index.php and index.html are in that order respectively.

image

Edited successfully and the Apache needs to be reloaded again by the command below.

image

Finally, we would create the PHP script to test that PHP is correctly installed and configured on the server. The importance is to be able to handle and process requests for PHP files with the command below

image

Put the edited file in an insert mode by typing “i” without quotes and add the valid PHP code files, press ESC , save and exit with “ :wq” command

image

Refresh the web page and you will see the web page server from a PHP perspective.

image

This is the minimum requirement to set up an AWS instance with LINUX, APACHE, MYSQL AND PHP for a web project.

Please note: Remember to terminate your EC2 instance.

If this post was helpful, Would be great if you could click the clap button 👏below to show your support.

Thank you for reading💚👏