LAMP Stack on Ubuntu: The Easiest Step-by-Step Guide

Welcome to the easiest step-by-step guide for setting up a LAMP (Linux, Apache, MySQL, PHP) stack on your Ubuntu server. Whether you’re a beginner or just looking for a quick refresher, this guide will walk you through the process seamlessly.

 

Step 1 – Installing Apache

Update the package list for upgrades and new packages:

sudo apt-get update

Now Apache can be installed.

sudo apt-get install apache2

Step 2 – Installing MySql

Install MySql Server

sudo apt-get install mysql-server

After MySql has been installed, you will need to set the root password of the database and secure it using the following command :

sudo mysql_secure_installation

You will be presented a screen where MySQL asks whether you would like to activate the VALIDATE PASSWORD PLUGIN. For now, keeping things simple, type no.

In the next type the root password of your choice. Confirm it again.

In the next screen MySql will ask whether to remove anonymous users. Type yes Disallow root login remotely?

Type No Remove test database and access to it?

Type Yes Reload privilege tables now?

Type Yes

After the password has been set you can check the whether MySQL is working correctly by logging into the database with the command :

sudo mysql -u root -p

Password is the same that was set in the previous step.

Step 3 – Installing PHP with Common Extensions

Now install PHP and commonly used PHP extensions by using the following command :

sudo apt-get install php libapache2-mod-php php-mysql php-curl php-gd php-json php-zip php-mbstring

After PHP has been installed, restart Apache.

sudo service apache2 restart

 

Conclusion:

Congratulations! You’ve successfully set up a LAMP stack on your Ubuntu server. This powerful combination of Linux, Apache, MySQL, and PHP provides a robust platform for hosting dynamic websites and applications. Feel free to explore further customization based on your specific needs. If you encounter any issues, refer to the official documentation or seek assistance from the community forums. Happy coding!

Leave a Comment