Cloud
Lamp

LAMP and PhpMyAdmin Configuration

A Guide to Setting Up a Local Web Development Environment

The LAMP stack is one of the most popular web development environments that has been used for years to build dynamic websites and applications. LAMP stands for Linux, Apache, MySQL, and PHP — four powerful technologies that work together to create a robust server environment.

In this blog, we will walk through how to set up the LAMP stack and integrate phpMyAdmin, a web-based database management tool that makes it easier to manage MySQL databases.

What is the LAMP Stack?

Before diving into the setup process, let's take a look at the components of the LAMP stack:

  1. Linux - The operating system that serves as the foundation for the stack.
  2. Apache - The web server software that delivers web content.
  3. MySQL - The database management system for handling data storage and retrieval.
  4. PHP - A server-side scripting language used for building dynamic web pages.

The combination of these four components allows you to develop and host websites locally or on a server with full control.

Installing the LAMP Stack

Step 1: Install Apache

Apache is a popular open-source web server. To install it, follow these steps based on your Linux distribution.

For Ubuntu/Debian-based systems:

sudo apt update
sudo apt install apache2
 
You can also display custom components like an alert:

Step 2 Install PHP

Install PHP and all required libraries:

sudo apt-get install php
sudo apt-get install php-dev php-gd php-pear php-curl
sudo apt-get install php-xmlrpc php-xsl
sudo apt-get install libapache2-mod-php
sudo service apache2 restart
Run the update command:
sudo apt-get update

Step 3 Install MySQL

sudo apt-get install mysql-server
sudo apt-get install php-mysql mysql-client
Note: Set MySQL root password to something you will remember
Run the update command again:
sudo apt-get update
mysql –version

Change password

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Password';
FLUSH PRIVILEGES;

Allow Specific IP to Access different Port

Configuring UFW for LAMP Stack with Specific IP Port Access

In this guide, we’ll walk through how to configure UFW (Uncomplicated Firewall) to allow specific ports used by a LAMP stack (Linux, Apache, MySQL, PHP) and restrict access to certain IP addresses.

What is UFW?

UFW is a front-end for iptables, designed to make managing a firewall easier. It is commonly used on Ubuntu and other Linux distributions for managing network traffic rules.

Default Ports for LAMP Stack

Here are the common ports used in a LAMP stack:

  • Apache (HTTP): Port
    80
  • Apache (HTTPS): Port
    443
  • MySQL: Port
    3306

For better security, it's a good practice to limit access to MySQL and other ports to only trusted IPs.

Basic UFW Commands

Before diving into specific port configuration, let's first review some basic UFW commands:

  • Check UFW status:

    sudo ufw status

sudo ufw allow from YOUR_IP_ADDRESS to any port 1433

sudo ufw allow from YOUR_IP_ADDRESS to any port 1433
sudo ufw allow from 192.168.18.238 to any port 1433
sudo ufw allow from YOUR_IP_ADDRESS to any port 80
sudo ufw allow from YOUR_IP_ADDRESS to any port 443
sudo ufw allow from YOUR_IP_ADDRESS to any port 3306