The LAMP stack is a popular and versatile set of open-source tools used for web server management. The acronym stands for Linux, Apache, MySQL/MariaDB, and PHP. This stack is ideal for those who want a robust and reliable platform to develop and host their websites. In this guide, we’ll walk you through the process of installing and configuring a LAMP stack on an Ubuntu server.

Introduction

Setting up a LAMP stack on a fresh cloud server is a straightforward way to get a web server up and running quickly. Whether you’re starting a new project or migrating an existing site, the LAMP stack provides a solid foundation for web development. Follow these steps to install and configure the LAMP stack on your Ubuntu server.

Step 1: Update Your Server

Before beginning the installation, ensure that your server’s package index is up to date:

 sudo apt update 
sudo apt upgrade


Step 2: Installing and Testing Apache2

Apache is a widely used web server that serves as the “A” in LAMP. To install Apache, use:

sudo apt install apache2


With the following command, confirm that Apache is currently running.

sudo systemctl status apache2


You should see output indicating that the apache2.service is active and running. To confirm that Apache is working,

Open a web browser and visit your server’s IP address. You should see the Apache2 default page.


Step 3 : Installing PHP 7.4

PHP is the scripting language that powers dynamic content on your site. Install PHP along with some common modules::

sudo apt install php7.4 php7.4-mysql php-common php7.4-cli php7.4-json php7.4-common php7.4-opcache libapache2-mod-php7.4

Check the installed php version:

php --version

Restart Apache for the changes to take effect:

sudo systemctl restart apache2

Step 4: Installing and securing MariaDB

Install the following packages:

sudo apt install mariadb-server mariadb-client

Once installed, make sure it’s up and running:

sudo systemctl status mariadb

 You should see an output similar to the example below.

Secure the newly installed MariaDB service:

sudo mysql_secure_installation

Follow the prompts to set up root passwords and remove insecure default settings.

Conclusion

Congratulations! You now have a fully operational LAMP stack with Linux, Apache, MariaDB, and PHP installed on your Ubuntu server. This powerful combination provides a solid foundation for developing and hosting your websites. You are now ready to begin developing your web applications and managing your content. Happy coding!