blog-image

Jan 15, 2024

22 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.

Note

If you want to skip all the technical steps of setting up LAMP on your server and have it installed in minutes, then I have some great news for you! Our team of engineers has prepared a ready-to-use 1-click LAMP application for your convenience. Just choose a server, and while prompted to choose the operating system, choose LAMP from the dropdown menu. This will set up LAMP in minutes. However, if you want to learn how to do it yourself, then keep reading.

Installing LAMP on Ubuntu 22.04 - Prerequisites

Before you proceed you'll need the following:
  • Root access to your server or a sudo user.
  • An Ubuntu 22.04 server with a non-root user with sudo privileges. If you haven't noticed, we offer extremely powerful Ubuntu servers at the globe's most affordable prices. Take a look at our offerings and prepare for your mind to be blown 🤯.
Check out our How to access your server using SSH guide to learn how to access your server and create 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
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.

Leave a Reply