LLMP Stack

How To Install the LLMP Stack (Linux, Lighttpd, MySQL, and PHP) on Ubuntu 24.04 or Newer

Welcome to the Greenhost.cloud blog! Today, we’re diving into the world of web hosting and server management by exploring how to install the LLMP stack on Ubuntu 24.04 or newer. LLMP stands for Linux, Lighttpd, MySQL, and PHP, and it is an excellent alternative to the more commonly known LAMP stack (with Apache). Lighttpd is known for its speed and efficiency, making it a great choice for serving dynamic web applications.

Whether you’re setting up a personal project or deploying a web application for your business, this step-by-step guide will help you get your LLMP stack up and running in no time.

Prerequisites

Before we begin, ensure that you have the following:

  1. Ubuntu 24.04 or newer installed on your server or local machine.
  2. Root or sudo privileges to install software packages.
  3. Basic knowledge of the terminal for command line operations.

Step 1: Update Your System

First, it’s always a good idea to update your package list to ensure you have the latest security updates and software versions. Open your terminal and run:

sudo apt update && sudo apt upgrade -y

Step 2: Install Lighttpd

Next, we’ll install Lighttpd, the lightweight web server.

sudo apt install lighttpd -y

After installation, start the Lighttpd service and enable it to run on boot:

sudo systemctl start lighttpd
sudo systemctl enable lighttpd

To confirm that Lighttpd is running, you can visit your server’s IP address in a web browser. You should see the default Lighttpd page.

Step 3: Install MySQL

Now, let’s install MySQL, the database management system for your LLMP stack. Use the following command:

sudo apt install mysql-server -y

Once installed, you’ll want to secure your MySQL installation. Run the following command and follow the prompts:

sudo mysql_secure_installation

This will allow you to set a root password, remove anonymous users, disallow root login remotely, and remove test databases.

Step 4: Install PHP

Next, we’ll install PHP along with the necessary extensions to work with Lighttpd and MySQL. Run the following command:

sudo apt install php php-mysql php-cgi php-pear php-dev -y

To ensure that Lighttpd recognizes PHP, we also need to install the lighttpd-mod-fastcgi module:

sudo apt install lighttpd-mod-fastcgi -y

After installing the module, enable it by running:

sudo lighty-enable-mod fastcgi
sudo lighty-enable-mod fastcgi-php

Finally, restart the Lighttpd service to apply the changes:

sudo systemctl restart lighttpd

Step 5: Test PHP Installation

To verify that PHP is working correctly with Lighttpd, create a test PHP file in the web server’s document root:

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Now, navigate to http://your_server_ip/info.php in your web browser. You should see the PHP information page displaying various settings and configurations.

Step 6: Secure Your LLMP Stack

For security reasons, it’s essential to remove the test PHP file:

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

Additionally, consider configuring your firewall to allow only necessary ports (like 80 for HTTP and 443 for HTTPS) and setting up SSL for secure communications.

Conclusion

Congratulations! You have successfully installed the LLMP stack (Linux, Lighttpd, MySQL, and PHP) on your Ubuntu 24.04 or newer server. You can now start building and deploying your web applications.

If you have any questions or feedback, feel free to leave a comment below. And don’t forget to check back for more tutorials and tips on managing your web hosting environment at Greenhost.cloud!

Happy coding!