How To Install PHP (LAMP) In Linux

how to install php or lamp in linux

In the last article, I showed you how to install PHP or XAMPP in Windows operating systems. And it was super easy. In this article, I’ll show you how to install PHP (LAMP) in Linux operating system. It’s really very simple to create PHP environment in Linux. So let’s get started.

What is LAMP?

LAMP stands for Linux, Apache, MySQL, and PHP. It’s really very simple to install PHP, a web server, a database system and PHP in a Linux box with LAMP. So let’s see how we can install it.

How to install LAMP in Linux?

You can tasksel to install LAMP. Tasksel is a package that provides many packages built in. So we’ll first install tasksel and then run it to install LAMP.

For the purpose of this article, I’m using Ubuntu. So all commands will work if you’re using any Debian based Linux. But, if you’re using Fedora or any RPM based Linux, simply use your distribution package manager to install the package. For example, if you’re using Fedora, you can use dnf package manager followed by the package name.

Install tasksel

For Debian based Linux –

sudo apt install tasksel

For Fedora Linux –

sudo dnf install tasksel

When the installation is done, simply run the tasksel with sudo.

sudo tasksel

run tasksel install lamp server in ubuntu with tasksel

And the installation will start.

installing lamp using tasksel

That’s it! You’re done. You’ve successfully installed Apache, MySQL, and PHP in your Linux distribution. You can confirm the installation by going to localhost in the browser.

localhost server is running

If you see the above page, then you’ve installed LAMP and the server is up and running.


Creating PHP environment is the first step into web development in PHP. You can now install your favorite code editors and start coding in PHP.

Author: Mohd Sohail

My name is Mohd Sohail, a commerce student and an IT lover by nature. I've been blogging for four years and like to write for almost each and every IT related thing that comes to my life.