Install LAMP stack on Ubuntu 22.04

Install LAMP stack on Ubuntu 22.04

Play this article

A LAMP Stack is a set of open-source software that can be used to create websites and web applications. LAMP is an acronym: these stacks typically consist of the Linux operating system, the Apache HTTP Server, the MySQL relational database management system, and the PHP programming language.

To install LAMP follow these steps.

Update the System

sudo apt-get update && sudo apt-get upgrade

Install MySQL

sudo apt-get install mysql-server mysql-client libmysqlclient-dev

Install Apache server

sudo apt install apache2 apache2-doc apache2-npm-prefork apache2-utils libexpat1 ssl-cert -y

Install PHP

Install Dependencies

To install PHP with success you have to install dependencies and to do so run the command bellow

sudo apt install software-properties-common apt-transport-https -y

Import PPA Repository of PHP

sudo add-apt-repository ppa:ondrej/php -y

After that, Update the System again.

Install PHP

Bellow command will install PHP Version 8.1, replace 8.1 with desired PHP Version.

sudo apt install php8.1 -y

Install the Apache PHP Module

sudo apt install libapache2-mod-php8.1 -y

According to the installed php version.

Install Nginx(PHP-FPM)

sudo apt install php8.1-fpm libapache2-mod-fcgid -y

According to the installed php version.

Install PHP Extensions

sudo apt install php8.1-common php8.1-curl php8.1-dev php8.1-gd php-pear php-imagick php8.1-mcrypt php8.1-mysql php8.1-ps php8.1-xsl

Customize and add other extension following the installed php version.