Linux

How to setup and configure a lamp stack

LAMP stands for Linux Apache Mysql php. This stack is an open source software use to deliver high performing web applications comprising of the above named applications. What this means is that these individual packages are installed together in a stack to enable a server to host dynamic websites and web applications. There are other versions of this setup for other operating systems such as WAMP/WIMP for Microsoft Windows and MAMP for MAC OS.

Apache is probably the most widely used web application; mainly maintained by an open source community.

Mysql is an open source relational database for storing application data. There are different relational databases you can use; the most commonly used database is the Mariadb.

PHP is a programming language used to create dynamic web pages in conjunction with Apache.  It is a relatively easy and efficient to use. You can also use perl instead of php.

STEPS TO SETUP THE LAMP STACK
Install Apache: Install the Apache package with the yum install httpd command.

When the installation is done, start the httpd service with the systemctl start httpd. You should also make it persistent across reboot with systemctl enable httpd this will make it active when you boot your system.

You can now test if the setup is working by inputting your system’s i.p address into the address bar of your web browser. This should display a test page that looks something like the image below.

Install and configure Mariadb
– Install the database package with yum install mariadb-server mariadb

Now start the database and enable Mariadb with the following commands;

systemctl start mariadb
systemctl enable mariadb

There are however some other configurations you need to include to secure your database such as creating an Admin user, changing the password and deleting the default user that is created when you install Mariadb.

Install the php package
– When installing the php package as part of a LAMP server, it is important to install it with the mysql extention.

After the installation, restart the httpd.service.

If you have a firewall up, you will need to allow firewall to allow http and https through.

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

To ensure that php is correctly installed, you need to create a basic script named info.php. This file should be stored in the /var/www/html directory.

vi /var/www/html/info.php

Here is a simple script that you can use to test the php setup;

                         <?php
                                     phpinfo();
                         ?> 

Save and quit your editor. Go to your web browser and type;

http://i.p-adress/info.php

The result of this when you hit the enter button should be an image that looks like the image below.

With the php package, there are some addition extensions you can find within the package. To find these packages, type the following into your terminal;

yum search php- This will bring an output of several additional php packages that may be useful.

You can then use yum install to install whatever additional package you want.

In summary, the LAMP stack allows for flexibility and efficiency; LAMP been an open source stack, there is a vast ecosystem of users and developers. It also a secure architecture and well established encryption practices.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x