The LEMP stack is a popular web server solution that consists of Linux, Nginx (pronounced "Engine-X"), MariaDB, and PHP. In this guide, we will walk you through the steps to install the LEMP stack on Debian 11.
Step 1: Update Your System
Start by ensuring your system is up to date:
sudo apt update && sudo apt upgrade -y
Step 2: Install Nginx
Install Nginx using the following command:
sudo apt install nginx -y
Start Nginx and enable it to start at boot:
sudo systemctl start nginx
sudo systemctl enable nginx
Step 3: Install MariaDB
Next, install MariaDB, which will serve as the database management system:
sudo apt install mariadb-server -y
Secure the MariaDB installation:
sudo mysql_secure_installation
Step 4: Install PHP
Now, install PHP along with the necessary extensions for Nginx:
sudo apt install php php-fpm php-mysql -y
Step 5: Configure Nginx to Use PHP
Edit the default Nginx server block configuration:
sudo nano /etc/nginx/sites-available/default
Modify the file to include the following configuration for PHP support:
server {
listen 80;
server_name your_domain_or_IP;
root /var/www/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Step 6: Test PHP Processing
Create a PHP info file to test if PHP is working with Nginx:
echo "" | sudo tee /var/www/html/info.php
Now open your web browser and go to http://your_domain_or_IP/info.php
. You should see the PHP information page.
Step 7: Restart Nginx
Restart Nginx to apply the changes:
sudo systemctl restart nginx
Conclusion
You have successfully installed the LEMP stack (Nginx, PHP, and MariaDB) on Debian 11. This powerful combination allows you to host dynamic websites and applications.
If you're looking for a reliable hosting solution for your LEMP stack, consider using Windows VPS UK. With Windows VPS, you can efficiently host your applications and ensure high performance. Whether you need VPS UK Windows or Windows Virtual Private Servers, you'll find a solution that fits your requirements.
For larger deployments or enterprise needs, explore Windows Virtual Dedicated Server Hosting or Virtual Private Server Hosting Windows. Whether you're located in the UK, Italy, or elsewhere, Windows VPS Italy and UK VPS Windows offer reliable hosting options. Visit Windows VPS Hosting UK to discover the best hosting solutions for your needs.