Introduction:

Ubuntu 24.04 LTS, codenamed “Xenial Xerus,” brings with it a host of exciting features and improvements, making it an excellent choice for developers and system administrators alike. With enhanced security, stability, and performance, it’s the perfect platform for hosting robust web applications. In this guide, we’ll walk you through the step-by-step process of installing LEMP on Ubuntu 24.04 LTS as well as the basic configuration.

New Features in Ubuntu 24.04 LTS:

Improved Security: Ubuntu 24.04 LTS includes enhanced security features, providing better protection against various cyber threats.

Updated Software Stack: This release comes with updated versions of essential software packages, ensuring compatibility with the latest web technologies.

Enhanced Performance: Performance optimizations make Ubuntu 24.04 LTS faster and more responsive, ideal for hosting high-traffic websites and applications.

Step-by-Step Guide to Installing a LEMP Stack:

Step 1: Update System Packages

Before installing any new software, it’s essential to update the system packages to ensure that you have the latest versions. Open a terminal and run the following commands:

sudo apt update
sudo apt upgrade

Step 2: Install Nginx

Nginx is a high-performance web server that will serve as the backbone of our LEMP stack. Install Nginx using the following command:

sudo apt install nginx

Once installed, start the Nginx service and enable it to start automatically on system boot:

sudo systemctl start nginx
sudo systemctl enable nginx

Step 3: Install MySQL (MariaDB)

MySQL is a powerful relational database management system. In Ubuntu 24.04 LTS, the default MySQL variant is MariaDB. Install it using the following command:

sudo apt install mariadb-server mariadb-client

After installation, secure your MariaDB installation by running the security script:

sudo mysql_secure_installation

Follow the on-screen prompts to set a root password and configure other security options.

Step 4: Install PHP

PHP is a popular server-side scripting language used for dynamic web content. Install PHP and necessary extensions with the following command:

sudo apt install php php-fpm php-mysql

Step 5: Configure Nginx to Use PHP

Next, configure Nginx to use PHP to process PHP files. Open the default Nginx server block configuration file:

sudo nano /etc/nginx/sites-available/default

Find the location ~ .php$ block and uncomment it, then modify it to use the unix:/run/php/php7.4-fpm.sock socket:

nginx

location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}

Save and close the file, then test the Nginx configuration for syntax errors:

sudo nginx -t

If no errors are reported, reload Nginx to apply the changes:

sudo systemctl reload nginx

Step 6: Test the LEMP Stack

Create a test PHP file in the Nginx document root directory to verify that PHP is working correctly:

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

Add the following PHP code to the file:


<?php

phpinfo();

// ChicagoCloud LEMP Guide

?>

Save and close the file, then visit http://your_server_ip/info.php in a web browser. You should see a page displaying detailed information about your PHP configuration.

Conclusion:

Congratulations! You are now done installing LEMP on Ubuntu 24.04 LTS. With Nginx serving as the web server, MariaDB providing database functionality, and PHP handling dynamic content, you now have a powerful platform for hosting your web applications. Take advantage of the new features and improvements in Ubuntu 24.04 LTS to build robust and secure web solutions.

If you’re looking for a reliable hosting provider that can host or manage your LEMP stack, you’ve come to the right place. Please feel free to check out our managed VPS and unmanaged VPS hosting plans!