Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security & DevOps Insights

  • Home
  • About
  • Advertise With US
  • Contact
  • Reviews
  • Toggle search form
Home » Linux » How to Install LAMP Stack on Ubuntu 18.04
  • Linux Shell Scripting 1
    Write a Shell Script that Count Lines and Words in a File Linux
  • Teams
    How to install Microsoft Teams on a macOS Mac
  • PlayF
    How to Install PlayonLinux on a Linux System Linux
  • Featured post.
    How to fix The Group Policy settings for BitLocker startup options are in conflict and cannot be applied Security | Vulnerability Scans and Assessment
  • Dellupdate 1
    Fix for security vulnerabilities in the BIOS firmware for some Intel Processors Windows
  • diag7
    How to run Windows Memory Diagnostics Tool on Windows Windows
  • Windows Server 2016 1
    All About Windows Server 2016 Windows Server
  • powerpoint 1280x720 1
    How to change the speller and proofing language in PowerPoint Microsoft Exchange/Office/365

How to Install LAMP Stack on Ubuntu 18.04

Posted on 22/12/202128/09/2023 Raphael Gab-Momoh By Raphael Gab-Momoh No Comments on How to Install LAMP Stack on Ubuntu 18.04
lampstack-feature-lamp-stack-ubuntu

The LAMP stack is a collection of open-source tools for developing web applications. In addition, an operating system, a web server, a database, and a programming language are all required for a web application to function. For a database-driven and dynamic website, each layer of software is critical. So, here’s a step-by-step tutorial on how to install LAMP Stack on Ubuntu 18.04. In this guide, I will walk you through how to install each of the components as it is important that we install each component of the stack separately. You can view similar guides from here: How to Configure Advanced PAM in Linux/ and How to locate directory file context and restore it with SELinux/ also differences between dnf and apt package managers/ and How to create and deliver a report on System Utilization on a Linux based OS

The acronym LAMP stands for the following programs:

Linux which is a free and open-source operating system.
Apache which is an HTTP Server 
MySQL which is a relational database management system.
PHP which is a scripting language. Please also take a look at this guide: How to setup and configure a lamp stack on CentOS.

Requirements for installing LAMP Stack on Ubuntu 18.04

Ubuntu user with sudo rights in Ubuntu 18.04 Bionic Beaver
The ability to use a terminal/command line
The apt package manager, which comes pre-installed in Ubuntu and other Debian-based distributions.

Steps to Install LAMP Stack on Ubuntu 18.04

Step 1: Update Package Repository Cache

Update the package repository cache to guarantee that the software is installed with the most recent versions. Therefore, to successfully install LAMP Stack on Ubuntu, you need to update package repository to the latest version. To do so, enter the command below.

sudo apt update

Step 2: Install Apache Server on Ubuntu 18.04

Run the following command in the terminal to install Apache:

sudo apt install apache2

Hit y which means yes & enter on your keyboard when prompted

apache-2
apache 2

It is alright but just to be sure we will run another command to check the status

sudo service apache2 status
status

Next, type the following command to see if the UFW firewall has an application profile for Apache:

sudo ufw app info "Apache Full"
ports
ports

To know how if installation works, we need to run the local IP address and specify the port highlighted above. Hence, we can get the IP by running the command.

curl http://icanhazip.com
ipaddress
how to get ip
apache2
apache 2

Step 3: Install MySQL and Create a Database

sudo apt install MySQL-server

To check if our MySQL-server has been installed, run the following commands below

#systemctl start MySQL. Service
#systemctl status MySQL. Service
mysql
MySQL running

Step 4: Install PHP

sudo apt install php libapache2-mod-php php-mysql 
php
php set up

The next step to install LAMP Stack on Ubuntu 18.04 is to change how Apache serves files when directories are needed. Thus, Apache scans for a file card named index.html by default. Rather than searching for the index.html file, we want it to look for the index.php file.

sudo nano /etc/apache2/mods-enabled/dir.conf
index
dir.conf

The command we ran gave us the output above, we need to swap the position of index.html and index.php so that index.php is number 2. After the swap we save and close the file.

how to install LAMP Stack on Ubuntu 18.04- index.php_
dir.conf

Press CTRL + X to save and close the file. Then, press y and ENTER to confirm.

Step 5: Restart Apache

We need to restart the Apache service for the modifications to take effect.

sudo systemctl restart apache2

Step 6: Test PHP Processing on Web Server

To confirm that you’ve installed LAMP Stack on Ubuntu 18.04, create a simple PHP script and save it in the “web root” folder. Meanwhile, this is required for Apache to correctly locate and serve the file. /var/www/html/ is the location of this directory.

Type the following command to generate a file in that directory:

sudo nano /var/www/html/info.php

This opens an empty nano file

how to install LAMP Stack on Ubuntu 18.04-empty-nano-file
empty nano file

To install LAMP Stack on Ubuntu 18.04, we need to type in the PHP code below:

<?php
phpinfo ();
?>

Then, press CTRL + X to save and close the file. Press y and ENTER to confirm.

To confirm that our LAMP stack on Ubuntu 18.04 is installed and working, Open a browser and type in your IP address/info.php

NOTE: only the IP address of the VM will make this work so run ip addr show in terminal and copy the ip.

 how to install LAMP Stack on Ubuntu 18.04-info.php_
php

Summary

Congratulations, we have successfully installed the LAMP stack on Ubuntu 18.04. This we did by installing each of the components individually and this is especially important for web development.

Rate this post

Thank you for reading this post. Kindly share it with others.

  • Share on X (Opens in new window) X
  • Share on Reddit (Opens in new window) Reddit
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Facebook (Opens in new window) Facebook
  • Share on Pinterest (Opens in new window) Pinterest
  • Share on Tumblr (Opens in new window) Tumblr
  • Share on Telegram (Opens in new window) Telegram
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Pocket (Opens in new window) Pocket
  • Share on Mastodon (Opens in new window) Mastodon
  • Share on Bluesky (Opens in new window) Bluesky
  • Share on Threads (Opens in new window) Threads
  • Share on Nextdoor (Opens in new window) Nextdoor
Linux Tags:MySQL, MySQL-server

Post navigation

Previous Post: How to Configure Advanced PAM in Linux
Next Post: Setup Public Load Balancer in Azure

Related Posts

  • Feature image nagios
    How to Install and Configure Nagios on Ubuntu Linux
  • sdfdghjk
    How to fix “Job for Mattermost service failed” error Linux
  • Synergy software kvm
    Why Software KVMs such as Synergy is replacing Hardware KVMs Linux
  • feature image
    How to install PostgreSQL on Ubuntu Linux
  • Rport
    RPORT the free and open source remote management tool Linux
  • screenshot 2020 05 05 at 22.42.35
    How to run Windows applications on Linux via WineHQ Linux

More Related Articles

Feature image nagios How to Install and Configure Nagios on Ubuntu Linux
sdfdghjk How to fix “Job for Mattermost service failed” error Linux
Synergy software kvm Why Software KVMs such as Synergy is replacing Hardware KVMs Linux
feature image How to install PostgreSQL on Ubuntu Linux
Rport RPORT the free and open source remote management tool Linux
screenshot 2020 05 05 at 22.42.35 How to run Windows applications on Linux via WineHQ Linux

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

sysadmin top30a

  • Linux Shell Scripting 1
    Write a Shell Script that Count Lines and Words in a File Linux
  • Teams
    How to install Microsoft Teams on a macOS Mac
  • PlayF
    How to Install PlayonLinux on a Linux System Linux
  • Featured post.
    How to fix The Group Policy settings for BitLocker startup options are in conflict and cannot be applied Security | Vulnerability Scans and Assessment
  • Dellupdate 1
    Fix for security vulnerabilities in the BIOS firmware for some Intel Processors Windows
  • diag7
    How to run Windows Memory Diagnostics Tool on Windows Windows
  • Windows Server 2016 1
    All About Windows Server 2016 Windows Server
  • powerpoint 1280x720 1
    How to change the speller and proofing language in PowerPoint Microsoft Exchange/Office/365

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,832 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon

Tags

AWS Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.