If you want to host dynamic PHP websites or applications like WordPress, Laravel, or Magento, learning how to install LEMP Stack on Ubuntu is one of the first steps. The LEMP stack combines Linux, Nginx, MySQL, and PHP to create a powerful and high-performance web hosting environment.
Ubuntu 26.04 makes deploying the LEMP stack easier with updated repositories and improved package support. This guide walks through the complete installation and configuration process.
LEMP stands for:
Together, these components allow Ubuntu servers to handle dynamic websites, APIs, and modern web applications efficiently.
Start by updating the package index:
sudo apt update
Install Nginx:
sudo apt install nginx
After installation, verify that the service is running:
sudo systemctl status nginx
If the firewall is enabled, allow web traffic:
sudo ufw allow 'Nginx Full'
You can now open your server IP address in a browser to confirm Nginx is working.
MySQL stores application data and user information for websites and PHP applications.
Install MySQL using:
sudo apt install mysql-server
Run the security script to harden the database configuration:
sudo mysql_secure_installation
This helps remove insecure defaults and improves database security.
Check the service status:
sudo systemctl status mysql
Nginx does not process PHP directly, so Ubuntu uses PHP-FPM for handling PHP requests.
Install PHP and required MySQL extensions:
sudo apt install php-fpm php-mysql
Verify the PHP version:
php -v
Ubuntu 26.04 installs PHP 8.5 by default.
For additional PHP features, you can also install common extensions:
sudo apt install php-curl php-gd php-mbstring php-xml php-zip
Create a directory for your website:
sudo mkdir -p /var/www/example.com
Create a new Nginx server block:
sudo nano /etc/nginx/sites-available/example.com
Add a PHP configuration that forwards .php requests to PHP-FPM using the Unix socket.
After saving the file, enable the configuration:
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
Test the configuration:
sudo nginx -t
Reload Nginx:
sudo systemctl reload nginx
Create a simple PHP info page:
echo "<?php phpinfo();" | sudo tee /var/www/example.com/info.php
Visit the page in your browser to verify PHP is processing correctly through Nginx and PHP-FPM.
After testing, remove the file for security reasons:
sudo rm /var/www/example.com/info.php
Learning how to install LEMP Stack on Ubuntu 26.04 gives you a strong foundation for hosting PHP applications and modern websites. With Nginx handling web traffic, MySQL managing databases, and PHP-FPM processing scripts efficiently, the LEMP stack remains one of the most reliable Linux web server environments available today.
Once your stack is working, you can continue by installing SSL certificates, deploying WordPress, or configuring multiple Nginx virtual hosts.
Java remains one of the most widely used programming platforms for servers, enterprise applications, Android…
Ubuntu users often download software directly from developer websites instead of using the default app…
Installing Ubuntu 26.04 LTS is only the first step toward building a smooth, secure, and…
What is a Software Supply Chain Attack? A software supply chain attack occurs when a…
When people ask how UDP works, the simplest answer is this: UDP sends data quickly…
Endpoint Detection and Response (EDR) solutions have become a cornerstone of modern cybersecurity, designed to…