Understanding Linux Package Manager: Deploying A Lamp Stack in Linux.

Understanding Linux Package Manager: Deploying A Lamp Stack in Linux.

posted 4 min read

A package manager in Linux is a command-line or graphical tool that automates the process of installing, updating, configuring, and removing software packages. It simplifies software management by handling dependencies, repositories, and system consistency.

Key Functions of a Package Manager:

Installation: Downloads and installs software packages from a repository.
Upgrades: Updates software packages to the latest versions.
Removal: Removes software packages from the system.
Dependency Management: Automatically resolves and installs any required dependencies for a package.
Package Integrity: Verifies the authenticity and integrity of packages.
Repository Management: Allows users to add or remove software repositories.

Why are Package Managers Important?

Simplified Software Management:
They automate the process of installing, updating, and removing software, making it easier for users to manage their systems.
Dependency Resolution:
They automatically handle dependencies, ensuring that all required packages are installed, which prevents "dependency hell".
Security and Integrity:
They help ensure that software packages are authentic and haven't been tampered with.
Centralized Repositories:
They allow users to access a centralized repository of software packages, making it easier to find and install software.

Example Workflow (Ubuntu):

Image description

Without wasting much time, let us begin by downloading Ubuntu's package manager. To do this, you need to download Ubuntu Multipass. After downloading and installing it successful , here is how it will look once you open the Multipass;

Image description

You will need to download an Ubuntu image.After the downloaded the image, open the instance on the left hand pane of the multipass app. Click on new terminal.

Image description

Once you open the shell a welcome note will appear, to clear that welcome note you will need to run the command "clear"

Image description

To install anything in Ubuntu, you need to be on admin mode. The command for that is "Sudo Su". Now if you do not want to be on admin mode (root mode)but still want to perform an installation, lets say you want to install NGINX, "Sudo apt install nginx"

Image description

NOTE:

Provided you're not in root mode, you will need to add "Sudo" to every command. Sudo gives you that administrative privilege.

DEPLOYING A LAMP STACK

The LAMP stack is a robust, open-source software suite used to build and host dynamic websites and web applications. A LAMP stack is a popular open-source software bundle used for building and hosting web applications. The acronym "LAMP" stands for the four core components: Linux, Apache, MySQL and PHP.

Here's a breakdown of each component:

Linux:
The open-source operating system that serves as the foundation for the LAMP stack, providing a stable and secure environment for running web applications.
Apache:
A widely used web server software that handles HTTP requests and delivers web content to users.
MySQL:
A relational database management system used for storing and managing data for web applications.
PHP:
A server-side scripting language used to create dynamic web content, interacting with MySQL to fetch and display data.

Step-by-Step Deployment

Step 1: System Update
To do this, run the command "sudo apt update && sudo apt upgrade -y"

Image description

Step 2: Install Apache Web Server
To install apache2, run the command "sudo apt install apache2 -y"

Image description

Step 3: Enable and start the service
Run the command "sudo systemctl enable apache2 --now"

Image description

To know if Apache2 is installed, run the command "ip addr show."

Image description

Copy the IP address and paste on a browser.

Step 4: Install MySQL Database
Run the command "sudo apt install mysql-server -y"

Image description

Step 5: Secure MySQL
Run the command "sudo mysql_secure_installation"

Image description

Step 6: Install PHP
Run the command "sudo apt install php libapache2-mod-php php-mysql php-cli php-curl php-json -y"

Image description

Step 7: Test PHP Configuration
Run the command echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Image description

Visit: http:// your IP address/info.php to view the PHP details page.

Image description

Step 8: Remove the test file afterward
Run the command sudo rm /var/www/html/info.php

Image description

Step 9: Security Best Practices

Configure Firewall
Allow only necessary traffic:

  1. Allow HTTP/HTTPS
    Run the command sudo ufw allow 'Apache Full'
  2. Allow SSH
    Run the cammand "sudo ufw allow ssh"
  3. Activate firewall
    Run the command "sudo ufw enable"

Image description

We have successfully deployed a LAMP Stack on Linux for hosting dynamic websites and web applications. That wasn't difficult.

If you read this far, tweet to the author to show them you care. Tweet a Thanks

Great guide man

This is a great guide on using package managers and setting up a LAMP stack! It’s super helpful for those new to the process. I especially appreciate how you explained each step clearly. Out of curiosity, do you think there are any specific security practices that are often overlooked when deploying a LAMP stack in real-world environments?

More Posts

Setup a LAMP Server on a VPS in Under an Hour: The Ultimate Guide to Web Hosting

Gift Balogun - Feb 19

Laravel 12 & Laravel Cloud: The Next Big Leap in Web Development

Snehal Kadwe - Mar 9

Building a Smart Contract in Rust for Solana: Minting and Deploying a New Token

Web3Dev - Feb 20

Why MERN Stack is Still a Top Choice for Web Development in 2025

Mohammad Yasir - Mar 16
chevron_left