DEV Community

Cover image for Understanding Linux Package Manager; Deploying A Lamp Stack in Linux
John Essien
John Essien

Posted on

Understanding Linux Package Manager; Deploying A Lamp Stack in Linux

Dearest readers! Lets build some cloud muscles by delving into Linux. In Linux, a package manager is a software tool that automates the process of installing, upgrading, configuring, and removing software packages, simplifying software management and ensuring dependencies are met.

Without further ado, lets go to the clouds!!


  • let us begin by downloading Ubuntu's package manager. To do this, you need to download Ubuntu Multipass. Hoping you have downloaded multipass successfully, you can launch it. The multipass should look like this:
    Multipass

  • After the multipass homepage, You will need to download an Ubuntu image. Based on my experience, you should download any of the Ubuntu 24.04LTS to Ubuntu 20.04LTS. Your network and system configuration may pose a problem here.
    Download Ubuntu image

  • After the downloaded the image, open the instance on the left hand pane of the multipass app. Click on new terminal.
    Terminal

  • 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"

Admin mode

  • To bypass any prompt stopping the installation, the command is "Sudo apt install -y"; this automatically installs any application without asking a Yes or No
    Bypass Yes or NO

  • NOTE: The rule behind every command is "Package manager name" >verb >name of what to install; That is "Apt >Install or Delete or upgrade or update >Nginx or Apache or PHP". However, 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. Its components work synergistically to deliver a scalable and cost-effective development environment.

Core Components
Linux: The operating system layer, providing a secure and stable foundation for the stack. Popular choices are Ubuntu, CentOS, Debian.

Apache: A high-performance web server that processes HTTP requests and serves web content.

MySQL/MariaDB: A relational database management system (RDBMS) for structured data storage. Enables complex queries, transactions, and user access control.

PHP: A server-side scripting language for creating dynamic content (e.g., user logins, forms).

Why Choose LAMP?

  • Cost-Effective: Fully open-source with no licensing fees.

  • Flexibility: Supports numerous plugins, frameworks (e.g., Laravel, Symfony), and CMS platforms (e.g., WordPress).

  • Community Support: Extensive documentation and troubleshooting resources.

  • Cross-Platform: Works on most operating systems.

Step-by-Step Deployment

Step 1: System Update
To do this, type "sudo apt update && sudo apt upgrade -y"
Ubuntu update and upgrade

Step 2: Install Apache Web Server
1: Install Apache: "sudo apt install apache2 -y"

Apache install

2: Enable and start the service: "sudo systemctl enable apache2 --now"

enable apache2

  • To know if Apache2 is installed, type "ip addr show."
    IP addr

  • Copy the IP address and paste on a browser
    Apache on browser

Step 3: Install MySQL Database
1: Type: "sudo apt install mysql-server -y"

SQL Installation

2: Secure MySQL: "sudo mysql_secure_installation"

SQL Secure

Step 4: Install PHP
Type: "sudo apt install php libapache2-mod-php php-mysql php-cli php-curl php-json -y". Oops I missed some of the code πŸ˜„πŸ˜„

Install PHP

1: Test PHP Configuration
Type: echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php"

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

2: Remove the test file afterward
Type: sudo rm /var/www/html/info.php

remove test fle

Step 5: Security Best Practices

  • Configure Firewall

Allow only necessary traffic:

  1. Allow HTTP/HTTPS
    sudo ufw allow 'Apache Full'

  2. Allow SSH
    "sudo ufw allow ssh"

  3. Activate firewall
    "sudo ufw enable"

Security practice


And just like that!!! We have successfully deployed a LAMP Stack on Linux for hosting dynamic websites and web applications!!! That was quite intense. Right?? We are definitely building some cloud muscle. Join me in the next article for more intense cloud workout.

COMMENT, LIKE, ASK QUESTIONS AND SHARE!!!

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

πŸ‘₯ Ideal for solo developers, teams, and cross-company projects

Learn more

πŸ‘‹ Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay