How to Install LAMP on Ubuntu 24.04

How to Install LAMP Stack on Ubuntu 24.04

This tutorial will teach you how to install LAMP on Ubuntu 24.04.

The LAMP stack is a shortcut for Linux, Apache, MySQL, and PHP. As we know, Ubuntu 24.04 is a Linux OS, Apache is a web server used for serving website files, MySQL is a database management system, and PHP is the programming language. This stack is used on millions of websites hosted on different servers. Every system administrator handles issues related to the LAMP stack daily.

Installing the LAMP stack on Ubuntu 24.04 is straightforward and may take up to 15 minutes. Let’s get started!

Prerequisites to install LAMP on Ubuntu 24.04

  • A server running Ubuntu 24.04 or any Linux OS
  • User privileges: root or non-root user with sudo privileges

Step 1. Update the system

Before we start with the installation of the LAMP stack we need to update the system packages to their latest versions available. To do that, execute the following commands:

sudo apt update -y && sudo apt upgrade -y

Step 2. Install Apache Web server

The Apache web server is open-source software written in C and can run on multiple operating systems such as Windows, Linux, OpenVMS, etc. According to the world statistics, the Apache web server is currently the most used, leading Nginx and Cloudflare as its concurrent.

To install the Apache web server, execute the commands below:

sudo apt install apache2 -y

Once the web server is installed, we need to start and enable the apache2 service:

sudo systemctl start apache2 && sudo systemctl enable apache2

To check the status of the service, execute the following command:

sudo systemctl status apache2

If everything is OK, you should receive the following output:

root@host:# sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; preset: enabled)
     Active: active (running) since Wed 2024-03-13 20:15:39 CDT; 3min 9s ago
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 58694 (apache2)
      Tasks: 55 (limit: 4624)
     Memory: 5.3M (peak: 5.4M)
        CPU: 102ms
     CGroup: /system.slice/apache2.service
             ├─58694 /usr/sbin/apache2 -k start
             ├─58695 /usr/sbin/apache2 -k start
             └─58696 /usr/sbin/apache2 -k start

Mar 13 20:15:39 host.test.vps systemd[1]: Starting apache2.service - The Apache HTTP Server...

Step 3. Install MySQL database system

MySQL is an open-source relational database management system. As a component of the LAMP stack MySQL is used by many database-driven web applications such as WordPress, Drupal, Joomla, etc. To install MySQL, execute the following command:

sudo apt install mysql-server -y

Once the MySQL server is installed, we need to start and enable the service:

sudo systemctl start mysql && sudo systemctl enable mysql

To check the status of the service, execute the following command:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
sudo systemctl status mysql

You should get output similar to this:

root@host:# sudo systemctl status mysql
● mysql.service - MySQL Community Server
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
     Active: active (running) since Wed 2024-03-13 20:40:18 CDT; 2min 55s ago
   Main PID: 59835 (mysqld)
     Status: "Server is operational"
      Tasks: 37 (limit: 4624)
     Memory: 365.1M (peak: 379.4M)
        CPU: 2.611s
     CGroup: /system.slice/mysql.service
             └─59835 /usr/sbin/mysqld

Mar 13 20:40:17 host.test.vps systemd[1]: Starting mysql.service - MySQL Community Server...
Mar 13 20:40:18 host.test.vps systemd[1]: Started mysql.service - MySQL Community Server.

Step 4. Install PHP

PHP is a “Hypertext Preprocessor” server-side scripting language used for creating dynamic web pages. It is widely used by developers around the world. As a part of the LAMP stack on Ubuntu 24.04, the included version of PHP in the Ubuntu 24.04 repository is PHP8.3. To install PHP8.3 with its extensions, execute the following command:

sudo apt install php8.3 php8.3-cli php8.3-{bz2,curl,mbstring,intl} -y

Once installed, you can check the PHP version with the command below:

php -v

You should get the following output:

root@host:~# php -v
PHP 8.3.0-1ubuntu1 (cli) (built: Jan 19 2024 14:00:34) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.0-1ubuntu1, Copyright (c), by Zend Technologies

PHP was the last software of the LAMP stack.

That’s it. You successfully installed the LAMP stack on Ubuntu 24.04. Of course, you do not have to do this on your own. Simply sign up for one of our NVMe VPS plans and submit a support ticket. Our admins will help you with any aspect of the LAMP stack on your server. Feel free to contact us. We are available 24/7.

PS. If you liked this post on how to install LAMP on Ubuntu 24.04, please share it with your friends on social networks or leave a comment in the comments section. Thank you.

Leave a Comment