How to Set Up LAMP Stack in Linux?
Last Updated :
05 Aug, 2024
Setting up a LAMP stack in Linux is a fundamental task for creating a powerful web server environment. LAMP stands for Linux, Apache, MySQL, and PHP, and together they provide a robust platform for developing and deploying web applications. This guide will walk you through the process of installing and configuring each component of the LAMP stack on a Linux system, ensuring you have a fully functional web server ready for your projects.
How to Install LAMP Stack in Linux?
We must install Apache web server, MySQL, and PHP to set up LAMP Stack in Linux. Before proceeding to see all the step-by-step process directly. Let's first check all the prerequisites to install the LAMP stack in Linux.
Prerequisites to Install LAMP Stack
Step 1: Checking Linux Distribution
Make sure you have Linux all set and running. To check which Linux distribution you have installed use the following command:
command : grep -E '^(VERSION|NAME)=' /etc/os-release
checking installed Linux distributionAnd follow the steps according to your installed Linux distribution.
Step 2: Upgrading Linux distribution to the latest packages.
For Ubuntu/Debian-based systems
We use the apt package manager to update and upgrade Ubuntu/Debian-based systems.
apt update will update all the packages to the latest versions and apt upgrade will download and install the required packages.
command : sudo apt update && sudo apt upgrade
For Fedora-based systems
In the fedora-based Linux distribution, we use dnf package manager.
dnf RHEL-based update which makingRHEL-basedupdate command will update repositories and download and install necessary updates.
command : sudo dnf update -y
For RHEL-based systems
On Red Hat Enterprise Linux distributions we use the yum package manager.
Similar to the DNF, package manager, the yum update command will update repositories and download and install necessary updates.
command : sudo yum update -y
Upgrading System 1. Installing Apache Web Server
Step 1: Install Apache Web Server using the package manager
On Ubuntu/Debian-based Fedora-based systems
Command: sudo apt install apache2 -y
On Fedora-based RHEL-based systems
Command: sudo dnf install httpd -y
On RHEL-based systems
Command: sudo yum install httpd -y
Installing Apache Web ServiceStep 2: Enable services
We will use the systemctl command to manage all Apache servers' or Debian-based services.
For Ubuntu/Debian-based systems
Command: sudo systemctl enable apache2
For Fedora-based systems
Command: sudo systemctl enable httpd.service
For RHEL-based systems
Command: sudo systemctl enable httpd.service
starting services for the Apache Web ServerStep 3: Verify Apache Web Server Installation
To verify Apache Web Server installation, use the -v command.
For Ubuntu/Debian-based systems
Command: apache2 -v
For Fedora-based systems
Command: httpd -v
For RHEL-based systems
Command: httpd -v
Verifying Apache web server installation2. Installing MySQL (MariaDB)
Step 1: Install MariaDB using the package manager
For Ubuntu/Debian-based systems
Command: sudo apt install mariadb-server mariadb-client
For Fedora-based systems
Command: sudo dnf install mariadb mariadb-server -y
For RHEL-based systems
Command: sudo yum install mariadb mariadb-server -y
installing MySQL (MariaDB)Step 2: Starting Services for MariaDB
Start required services for MariaDB using systemctl command
Command:
sudo systemctl start mariadb
sudo systemctl enable mariadb
enabling services for MySQL (MariaDB)Step 3: Verify MySQL Installation
To verify MySQL installation, use the --version command.
Command: mysql --version
verifying MySQL installation 3. Installing PHP
Step 1: Install PHP
For Ubuntu/Debian-based systems
command : sudo apt install php -y
For Fedora-based systems
command : sudo dnf install php -y
For RHEL-based systems
command : sudo yum install php -y
Installing PHPStep 2: Verify installation
To verify php installation, use the --version command.
Command: php --version
Verifying phpConclusion
Setting up a LAMP stack in Linux is a straightforward process that provides a solid foundation for web development. By following the steps outlined in this guide, you can successfully install and configure Linux, Apache, MySQL, and PHP on your server. With a properly set up LAMP stack, you'll be well-equipped to develop, test, and deploy web applications efficiently and effectively.
Similar Reads
How to Install Xampp in Linux XAMPP is a popular and free open-source platform primarily used for PHP development. It comes bundled with essential tools like Apache Web Server, MySQL (MariaDB), PHP, Perl, and more, making it a one-stop solution for web development. Installing and setting up XAMPP is streamlined, and the package
6 min read
How to Install PHP on Linux? PHP is a popular server-side scripting language that is especially used in web development. If you're working on a Linux environment, whether it's a personal development setup or a production server, you will likely need PHP installed. In this article, we will see the step-by-step guide to install P
2 min read
How To Install WordPress On Rocky Linux 9 WordPress is widely recognized as the preferred platform for building websites and blogs due to its ease of use and wide range of customization features. Suppose you're considering installing WordPress on Rocky Linux, an open-source operating system known for its reliability. In that case, you'll fi
5 min read
How to install Zabbix on Linux A system administrator's duties include network management. Zabbix is a free and open-source monitoring tool for administering and monitoring networks. This software is open-source and free, and it has a tonne of functionality. Zabbix is used to monitor resources in the cloud as well as networks, se
2 min read
How To Install WordPress On Redhat Linux 9 Installing WordPress on Red Hat Linux 9 can be a great way to create a dynamic website or blog. In this guide, we will walk you through the installation process step by step. Before we begin, make sure you have a Red Hat Linux 9 system set up and have administrative access to install software. Table
5 min read
How to Install WordPress on Kali Linux Installing WordPress on Kali Linux can be a useful endeavor, whether for development, testing, or learning purposes. WordPress is a popular content management system (CMS) that allows you to create and manage websites easily. In this article, we will guide you through the process of installing WordP
4 min read
How to Install Nginx in AWS Linux ? Nginx is a simple web server that can be used for multiple purposes such as load balancer, reversal proxy & HTTP cache as well, the software was created by Igor Sysoev, a Russian developer and it was released in the year 2004. the reason why nginx is popularly used is because it is an open-sourc
8 min read
How to Install WordPress on the Linux Apache MySQL and PHP stack ? WordPress is one of the commonly used Content Management systems on the web. It is written in PHP web servers like Apache are enough to run it. WordPress supports MySQL and MariaDB, but MySQL is widely used. This tutorial will help you to run WordPress using the LAMP(Linux, Apache, MySQL, PHP) stack
8 min read
How to Install PHP on Alpine Linux? Alpine Linux is a Linux distro that is lightweight and security-focused. The main aim of alpine is to be minimalistic be it in scope or space. Since it is small in size it is used in those containers which require less time for booting. Unlike other distros which use GNU, Glibc alpine used musl, bus
2 min read
How to Set Up Apache Web Server in AWS EC2 Linux (Ubuntu) Instance? In this article, we will look into the process of setting up Apache Web Server in AWS EC2 Linux Instance.This tutorial has been done on a system running Windows 10 Home (Version 20H2).Implementation:The steps taken to complete this tutorial are being stated below:Step 1: Go to portal.aws.amazon.com
4 min read