Install Linux, Apache, MySQL, PHP (LAMP) Stack on Ubuntu 22.04 LTS

Introduction

LAMP is the stack of LinuxApacheMySQL and PHP, We can deploy PHP based project on LAMP server and also LAMP is so popular for WordPress CMS to build a website for their client, We can install LAMP server on AWSAzure/GCP and other cloud platform and scale also.

Know about LAMP Stack

Linux – Linux is a Unix-like operating system that uses a command line interface. It is one of the most popular operating systems on the internet and is used by a wide variety of organizations, from small home offices to large corporations. Linux is free and open source software, meaning that it is distributed under a license that allows anyone to use, copy, modify, and distribute it.

MySQL – MySQL is a relational database management system that is freely available. Its name is a combination of “My,” which is the name of the daughter of co-founder Michael Widenius, and “SQL,” which is an abbreviation for Structured Query Language.

PHP – PHP is a server side scripting language designed specifically for web development, created it in 1993 and released it in 1995. The PHP Group now produces the PHP reference implementation.

Apache – The Apache HTTP Server is a free and open-source cross-stage web server programming, delivered under the terms of Apache Permit 2.0. Under the direction of the Apache Software Foundation, an open community of developers develops and maintains Apache.

In this post, We will know how to install LAMP server on ubuntu 22.04 LTS.

Prerequisites

You will need an Ubuntu 22.04 server, a non-root sudo-enabled user account, and a basic firewall to finish this tutorial.

Step 1: Update the System

We need to update the cache of the package manager by using the gievn command.

sudo apt-get update 

Step 2: Install Apache Web server

After updating the ubuntu current repo, We are good to install apache2 package using following command.

sudo apt-get install apache2 -y

Step 3: Verify the Apache Service

After installation of apache2 package, We need to check apache2 service is running or not, Kindly use the following command for the same.

sudo systemctl status apache2.service

You have have up and ruuning apache2 service after execution the above command.

Note: To use the apache web server from outside the private network, you must either enable or disable port 80 in your OS lever and network lever firewalls.

Step 4: Installing PHP

In this step, We need to install PHP and required PHP module, Use the follwing command for the same.

sudo apt-get install php php-curl php-json php-cgi php-gd php-mbstring php-xml php-xmlrpc libapache2-mod-php php-mysql -y

Step 5: Integrate PHP with Apache

We need to execute the follwing command to integrate the PHP with Apache web server.

sudo a2enmod php

Before the enabled mod can be loaded, the Apache web service needs to be restarted.

sudo systemctl reload apache2

Step 6: Installing MySQL Server

In order to install MariaDB server on ubuntu, You need to execute the given command for the same.

sudo apt-get install mysql-server -y

To check MySQL service.

sudo systemctl start mysql.service

Use the following command as the root user to secure the MySQL server after the aforementioned packages have been successfully installed.

sudo mysql_secure_installation

You will asked for the some configuration and security setting, You should choose the option as per your need.

Step 7: Testing PHP with Apache Web Server

We need to create a php file and add given code to get PHP information using apache web server endpoints.

Create a phpinfo.php file in /var/www/html location.

sudo echo "<?php phpinfo();?>" > /var/www/html/phpinfo.php

After that, you need to enter the given URL into the web browser, You need to open the browser witg given web address to get PHP information test page.

http://localhost/phpinfo.php or http://IP_Address/phpinfo.php

You should get web page like this.

Conclusion

We have successfully installed the LAMP server on ubuntu 22.04 LTS, If you still have questions, please post them in the comments section below.

Author

Install Linux, Apache, MySQL, PHP (LAMP) Stack on Ubuntu 22.04 LTS

10 thoughts on “Install Linux, Apache, MySQL, PHP (LAMP) Stack on Ubuntu 22.04 LTS

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top