How To Setup LAMP Stack on Parrot OS - CyberSec Nerds

How To Setup LAMP Stack on Parrot OS

If you want to get started building dynamic web applications on your Parrot machine, then chances are you will be wanting to use a LAMP stack to build and possibly deploy your work.

Introduction

The “LAMP” stack of software, consisting of the Linux operating system, Apache web server, MySQL database, and PHP scripting language, is a great foundation for web or application development. Installed together, this software stack enables your server to host dynamic websites and web applications. Let’s look at the functions of each component:

  • Linux — Open-source Operating System on which all these required packages are installed. Linux is popular in part because it offers more flexibility and configuration options than some other operating systems.
  • Apache Web Server — The Apache web server processes requests and serves up web assets via HTTP so that the application is accessible to anyone in the public domain over a simple web URL.
  • MySQL RDBMS — With My SQL, you can store all your information in a format that is easily queried with the SQL language. SQL is a great choice if you are dealing with a business domain that is well structured, and you want to translate that structure into the backend.
  • PHP — The PHP open-source scripting language works with Apache to help you create dynamic web pages. You cannot use HTML to perform dynamic processes such as pulling data out of a database. To provide this type of functionality, you simply drop PHP code into the parts of a page that you want to be dynamic.

*RDBMS stands for Relational Database Management System
*PHP is an acronym for HyperText Preprocessor

In this tutorial, we’ll install a LAMP stack on a local Parrot OS version 5.6.

Step 1 — Installing Prerequisites

This procedure assumes that Parrot is already installed on your machine. If you need to install it, you can go to this link.

After you have your operating system up and running, you’ll want to make sure that everything on your system is current. To update your package lists, open up your terminal and type:

$ sudo apt-get update

 The result should look something like the screenshot below. Note that this and the following screenshots show the end of each command as it is completed, and so do not necessarily illustrate the entire process.

apt-get update

$ sudo apt-get upgrade

apt-get upgrade

Step 2 — Installing Apache

The very heart of our LAMP stack is a piece of server software called Apache. A web server’s job is to process HTTP requests, which are used to send information across the Internet.

Why are we choosing Apache? Because it’s the world’s most popular web server software, it’s extremely stable, it’s well-supported, and it’s completely open-source, which means you don’t have to pay anything for it. This is a well-documented and widely used web server that will allow your server to display web content.

To install Apache, type the following command into the Terminal:

$ sudo apt-get install apache2 apache2-doc

This installs the basic Apache web server package as well as the documentation that goes along with it. This may take a few seconds as Apache and its required packages are installed.

After apache2 installation, let’s start the web server by typing the following command:

$ systemctl start apache2

You can check the status of the server with this command.

$ systemctl status apache2

checking status of apache web server

Voilà! You should now have a running web server on your machine. To check this, go to http://localhost/, where you should see a page saying “It works!”

default page of apache web server

Step 3 — Installing and Securing MySQL

The next component of the LAMP server is MySQL. This relational database software is an essential back-end component for other software packages such as WordPress, Joomla, Drupal, and many others.

To install MySQL, type the following into the Terminal:

$ sudo apt-get install mysql-server

During the process of installing MySQL, you will be prompted to set a root password. This is the password you’ll use for the MySQL install. You can choose to set it now, or you can do so later, within the MySQL shell.

setting mysql-server password

After MySQL has finished installing, it starts automatically. To log into your server, use the following command (you will be prompted for your root password):

$ mysql -u root -p

Point to be Noted: In MySQL, by default, the username is root and there’s no password.

In case your MySQL server is not running, you can perform the same steps as we did in the Apache section. I mean, use the commands below to start and check the status of MySQL-server.

$ systemctl start mysql-server
$ systemctl status mysql-server

From there, you can start to play with this RDBMS and set up new databases and users.

Important: MySQL’s original role as the LAMP’s relational database management system (RDBMS) has since been alternately provisioned by other RDBMSs such as MariaDB or PostgreSQL, or even NoSQL databases such as MongoDB.

Step 4 — Installing PHP

For our last component, we will set up and install PHP, which stands for Hypertext Preprocessor. This popular server-side scripting language is used far and wide for dynamic web content, making it essential to many web and application developers.

To install PHP, type the following:

$ sudo apt install php libapache2-mod-php

After you agree to the installation, PHP will be installed on your server. You will see many packages being installed beyond just PHP. Don’t worry; your system is integrating the PHP software with your existing Apache2 installation and other programs.

Restart Apache on your server to make sure all of the changes with the PHP installation take effect. To do this, type the following:

$ sudo service apache2 restart

Step 5 — Testing Our Installation

Now, let’s take a moment to test the PHP software that you just installed. Move into your public web directory:

$ cd /var/www/html

Once there, use your favorite console text editor to create a file named info.php. Here’s one method of doing this:

$ sudo nano info.php

This command will use the command line editor nano to open a new blank file with this name. Inside this file, type the following to populate a web page with output information for your PHP’s configuration:

editing info.php

Hit CTRL-O  and Enter to write out the file, then CTRL-X  to exit. To access the configuration info, open your web browser and type the following URL. [This URL only works inside the Parrot machine]

localhost/info.php

But, if you want to access this web page from devices on the same network other than this Parrot machine, go to the URL below, replacing the XXX section with the server’s IP address. [However, a few other settings need to be done.]

http://XXX.XXX.XXX.XXX/info.php

If you’ve done everything correctly, you will see the default PHP information page, like the one shown below:

Displaying PHP version

When you are done looking at this test PHP page, remove it for security. To do that, run this command:

$ sudo rm -i /var/www/html/info.php

Closing Words

Congrats! Just like that, you’ve installed a basic LAMP Stack on Parrot OS, giving you a platform to create a wide range of websites and web applications. From here, you can start to play with PHP, you can see how the MySQL store and retrieve data — and begin building your very own web apps — in order to customize and extend the capabilities of your server. Have a great time ahead, folks!

Are you blaming yourself for poor-memory because you keep forgetting the Linux commands? Then you will surely want to check out my article How To Easily Remember Linux Commands?

Kiran Dawadi

Founder of cybersecnerds.com. Electronics Engineer by profession, Security Practitioner by passion. I am a Linux Enthusiast and highly interested in the offensive side of the CyberSec industry. You will find me reading InfoSec blogs most of the time.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments