How to Install LEMP Server on Ubuntu 22.04

The LEMP stack, comprised of Linux, Nginx, MySQL, and PHP, is a robust solution for hosting dynamic websites and applications. In this guide, we’ll walk through the step-by-step process of setting up a LEMP server on Ubuntu 22.04. Follow these instructions carefully to establish a powerful web server environment.

Update and Upgrade System Packages

Begin by ensuring that your system is up-to-date. Open a terminal and execute the following commands:

sudo apt update
sudo apt upgrade -y

These commands will refresh the package lists and upgrade existing packages to their latest versions.

Install Nginx Web Server

Nginx is a high-performance web server known for its efficiency and speed. Install it with the following command:

sudo apt install nginx -y

This command installs Nginx on your system.

Install MySQL Server

MySQL serves as the relational database management system in our LEMP stack. Install it using the following command:

sudo apt install mysql-server -y

During the installation, you’ll be prompted to set a root password for MySQL. Choose a secure password and proceed.

Secure MySQL Installation

Enhance the security of your MySQL installation by running the MySQL Secure Installation script:

sudo mysql_secure_installation

Follow the on-screen instructions, addressing aspects such as setting the root password, removing anonymous users, and more. Respond with ‘y’ for yes and ‘n’ for no based on your preferences.

Install PHP and PHP-FPM

PHP, coupled with PHP-FPM, is essential for server-side scripting in the LEMP stack. Install PHP and the necessary modules with the following command:

sudo apt install php-fpm php-mysql -y

This command installs PHP along with PHP-FPM and the required modules for seamless communication with MySQL.

You’ve successfully established a LEMP server on Ubuntu 22.04. This powerful stack provides a solid foundation for hosting a variety of web applications and dynamic websites. To verify your setup, create a simple PHP file in the Nginx web root directory and access it through your web browser.

 

About the author

Technical Sahil

Sahil Dhamija is a visionary entrepreneur and tech enthusiast, proudly owning multiple companies across India, the US, the UK, and the UAE. As the founder of AInventions Technologies LLC, DigitalMarkethink Solutions LLC, WebReinvent Technologies LLC, BusinessMate Software Solutions LLC, and co-founder of Hostyaga FZE LLC, Sahil is a dynamic leader shaping the future of technology and digital marketing.

Apart from leading his businesses, Sahil is a passionate tech YouTuber, sharing insights and tutorials on various technological topics. He also serves as the CTO at Vayuna Corporate Travels Pvt Ltd and as Product Head at Vayuna Voicetech Pvt Ltd, where he oversees cutting-edge solutions in corporate travel and voice technology. Additionally, Sahil is a creative force in the film industry, producing films through Gentle Breeze Films Pvt Ltd.

Driven by innovation and creativity, Sahil continues to push boundaries in technology, media, and business.

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *