blog-image

Jan 15, 2024

20 min read

Simple Guide – How to Install LAMP on Ubuntu 22.04

Written by

Marc Chartouny
Are you looking for a simple tutorial on how to install LAMP on Ubuntu 22.04? You're in the right place! In this guide, you'll learn what a LAMP stack is in Linux, what a LAMP stack is used for, and how to install LAMP on Ubuntu 22.04.

What is a LAMP Stack in Linux?

A LAMP stack in Linux refers to a software bundle comprising Linux as the operating system, Apache as the web server, MySQL (or MariaDB) as the database system, and PHP (or Perl/Python) as the scripting language, commonly used for web development.

What is a LAMP Stack Used for?

A LAMP stack is used for building and deploying dynamic websites and web applications, combining Linux, Apache, MySQL, and PHP (or Python/Perl) components.

What Does LAMP Stack Stand for?

LAMP Stands for "Linux, Apache, MySQL, and PHP." Together, these software technologies can be used to create a fully-functional web server. Linux is the most popular, secure and open source operating system used in web servers. Apache HTTP Server is a free and open-source web server that delivers web content through the internet. MySQL is a relational database engine that allows you to store data and manage it. PHP is a widely used open source and general purpose server side scripting language used mainly in web development to create dynamic websites and applications. NOTE: In this tutorial, we’ll be using MariaDB— a backward compatible, drop-in replacement of the MySQL® Database Server, which includes all major open source storage engines, and allows you to manage relational databases for storing and organizing data.

Installing LAMP on Ubuntu 22.04 - Prerequisites

Before you proceed you'll need the following:
  • Root access to your server or a sudo user.

How to Install LAMP on Ubuntu 22.04

How to Install LAMP on Ubuntu 22.04 To install LAMP on Ubuntu 22.04, you will use the apt package manager to install Apache, MySQL, and PHP, and then ensure they are properly configured and integrated for web development. Apply the following steps to accomplish this.

Step 1: Update The Package Cache

Before you install LAMP, start by updating the Ubuntu packages in the package manager cache to the latest available versions using the following command:
sudo apt update
install lamp on ubuntu 22.04: Updating the System

Step 2: Install the MariaDB Database Server

After updating our Ubuntu package cache, we will now install the MariaDB database server, the M in the LAMP acronym. We'll use MariaDB instead of MySQL because it includes more features and supports new storage engines, in addition to its high performance. To install MariaDB, execute the following command:
sudo apt install mariadb-server mariadb-client
Tap the y key then Enter to continue the installation. In the preceding command, you install two packages:
  • mariadb-server: The MariaDB database server which actually stores data.
  • mariadb-client: The MariaDB database client which allows you to interact with and manage the database server via the command line.
Once the installation is finished, verify that the MariaDB database server is running properly by executing the following command to check out the MariaDB service status:
sudo service mariadb status
The output should show that the service is enabled and running: install lamp on ubuntu 22.04: MariaDB Here, you can see that the service is active and running in the line "Active: active (running) ...".

Ensure That MariaDB Starts at Boot

To make sure that the MariaDB database server starts with the system at boot, use the enable subcommand of the systemctl command. To do so, execute the following command:
sudo systemctl enable mariadb.service
You should receive the following output:
Synchronizing state of mariadb.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable mariadb

Securing The MariaDB Database Server

MariaDB comes with some unsafe default settings which may expose your database server to dangerous security vulnerabilities. It's recommended that you run a security script that comes with MariaDB to strengthen your database server and minimize the risk of database intrusions or breaches. To secure your MariaDB database server, execute the following command, where you will be presented with seven prompts: First, run the script:
sudo mysql_secure_installation
You’ll be asked for your current root password:
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 
Tap Enter. Next, you'll be
Continue reading this article
by subscribing to our newsletter.
Subscribe now

A note about tutorials: We encourage our users to try out tutorials, but they aren't fully supported by our team—we can't always provide support when things go wrong. Be sure to check which OS and version it was tested with before you proceed.

If you want a fully managed experience, with dedicated support for any application you might want to run, contact us for more information.