The LEMP stack consists of Nginx, PHP, and MySQL, which are necessary for running dynamic web applications. In this guide, you will learn how to install the LEMP stack on Ubuntu 22.04.

Step 1: Update the System

Before starting the installation, ensure your server is up-to-date by running the following command:

sudo apt update && sudo apt upgrade

Step 2: Install Nginx

Nginx is a high-performance web server. To install it, use the following command:

sudo apt install nginx

After installation, start and enable the Nginx service:

sudo systemctl start nginx
sudo systemctl enable nginx

Step 3: Install MySQL

Next, you need to install MySQL, a popular database management system:

sudo apt install mysql-server

After installation, run the security script to secure your MySQL installation:

sudo mysql_secure_installation

Step 4: Install PHP

To install PHP, which will process the dynamic content, use the following command:

sudo apt install php-fpm php-mysql

PHP-FPM (FastCGI Process Manager) is used to handle PHP requests in conjunction with Nginx.

Step 5: Configure Nginx to Use PHP

Now, configure Nginx to process PHP scripts by editing the default configuration file:

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

Look for the following lines and modify them:


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

After making changes, restart Nginx:

sudo systemctl restart nginx

Step 6: Test PHP

To verify that PHP is working correctly with Nginx, create a test PHP file:

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

Add the following content:

<?php phpinfo(); ?>

Now, navigate to http://your_server_ip/info.php in your browser. You should see the PHP information page.

Conclusion

You have successfully installed the LEMP stack on Ubuntu 22.04. Your web server is now ready to serve dynamic web content using Nginx, PHP, and MySQL.

If you're looking for reliable VPS hosting for your project, consider using Windows VPS UK solutions. With Windows VPS, you can easily set up and manage virtual private servers that are tailored for both Linux and Windows environments. Explore VPS UK Windows options for fast and reliable performance, whether you need a Windows Virtual Private Server for hosting or a Windows Virtual Dedicated Server for more demanding applications.

Hosting providers like Windows VPS UK offer services across Europe, including Italy and the UK, making them an ideal choice for Windows VPS Italy or UK-based businesses. Whether you're looking for Windows VPS Hosting in the UK or other virtual private server hosting solutions, you can find reliable and affordable options for your project. For more information on hosting solutions, visit Windows VPS UK.

¿Fue útil la respuesta? 0 Los Usuarios han Encontrado Esto Útil (0 Votos)