How to Install LEMP Stack on Ubuntu 24.04.1 LTS
The LEMP stack is one of the most practical foundations for modern web hosting. It combines Linux, Nginx, MariaDB, and PHP into a fast and flexible platform for running WordPress, Laravel, custom PHP applications, APIs, and lightweight web services. On Ubuntu 24.04.1 LTS, you also get a stable long-term support base with current package versions and predictable maintenance.
In this guide, we deploy a fresh Ubuntu 24.04.1 LTS server on Shape.Host CloudStack, install the latest practical LEMP components for this platform, configure Nginx with PHP-FPM, install MariaDB 11.8 from the official MariaDB repository, and verify the stack with a live browser test page.
What Is a LEMP Stack?
LEMP stands for Linux, Engine-X (Nginx), MariaDB, and PHP. It is a popular alternative to the traditional LAMP stack because Nginx is efficient under concurrency, PHP-FPM integrates cleanly with it, and MariaDB offers a mature open-source database platform with excellent compatibility.
Stack Versions Used in This Tutorial
| Component | Version Verified | Source |
|---|---|---|
| Ubuntu | 24.04.1 LTS | Fresh Shape.Host VM deployment |
| Nginx | 1.24.0 | Ubuntu 24.04 package |
| PHP | 8.3.6 | Ubuntu 24.04 package |
| MariaDB | 11.8.6 | Official MariaDB 11.8 repository |
Why Use LEMP on Ubuntu 24.04.1 LTS?
- Nginx handles concurrent traffic efficiently and is widely used for reverse proxy and application hosting.
- PHP 8.3 delivers strong performance and is compatible with most current PHP applications.
- MariaDB 11.8 gives you a current long-term support database branch without relying on older distro defaults.
- Ubuntu 24.04.1 LTS provides long support windows, stable package maintenance, and a familiar server administration experience.
LEMP vs LAMP
| Stack | Web Server | Best Fit |
|---|---|---|
| LEMP | Nginx | High-concurrency PHP sites, reverse proxy setups, leaner web serving |
| LAMP | Apache | Legacy PHP apps, heavy .htaccess workflows, Apache module compatibility |
Prerequisites
- A fresh Ubuntu 24.04.1 LTS server
- Root or sudo access
- An IPv4 address reachable on port 80
- At least 2 vCPU, 4 GB RAM, and 50 GB storage for a comfortable base deployment
1. Verify the Operating System
Start by confirming that the server is running Ubuntu 24.04.1 LTS.
cat /etc/os-release

2. Update the Server and Install Base Utilities
Update the package index, apply upgrades, and install the tools needed for repository management and package handling.
apt-get update
apt-get -y upgrade
apt-get install -y curl ca-certificates gnupg lsb-release apt-transport-https software-properties-common unzip

3. Install Nginx and PHP 8.3
Ubuntu 24.04 ships with PHP 8.3, which makes it a convenient base for modern PHP applications. Install Nginx, PHP-FPM, and the most common PHP modules you will need for dynamic websites.
apt-get install -y nginx php-fpm php-cli php-mysql php-curl php-xml php-mbstring php-zip

4. Add the Official MariaDB 11.8 Repository
Ubuntu’s default database packages are not always the newest branch you may want for a fresh application stack. For this deployment, we added the official MariaDB 11.8 repository before installation.
curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- --mariadb-server-version=mariadb-11.8

5. Install MariaDB Server and Client
Once the MariaDB repository is configured, refresh the package index and install the server and client packages.
apt-get update
apt-get install -y mariadb-server mariadb-client

6. Configure Nginx, PHP-FPM, and a Test Site
To verify the full LEMP path, create a simple PHP application, enable PHP handling in Nginx, and configure a local MariaDB-backed test page. A minimal default server block for Ubuntu 24.04.1 looks like this:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm;
server_name _;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
}
After writing the server block and the test page, validate Nginx and reload the service:
nginx -t
systemctl reload nginx

7. Verify the Installed Versions
Use the following commands to verify the exact versions on your server:
nginx -v
php -v
mariadb --version
On this Shape.Host deployment, the installed versions were:
- Nginx 1.24.0
- PHP 8.3.6
- MariaDB 11.8.6

8. Confirm the LEMP Stack in a Browser
Finally, open your server IP address in a browser. The demo page below confirms that PHP-FPM is running behind Nginx and that the PHP application can connect to MariaDB successfully.

Conclusion
You now have a working LEMP stack on Ubuntu 24.04.1 LTS with Nginx 1.24.0, PHP 8.3.6, and MariaDB 11.8.6. This combination is a strong starting point for PHP applications, content management systems, APIs, and custom websites that benefit from Nginx performance and a current MariaDB branch.
If you plan to use this server in production, the next sensible steps are enabling HTTPS, tightening your Nginx server blocks, restricting database access, and deploying your application code on top of this verified base stack.