LAMP is the stack of Linux, Apache, MariaDB 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 AWS/ Azure/GCP and other cloud platform and scale also.
LAMP Stack component overview.
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.
MariaDB – MariaDB is a popular open source database server. It is a fork of the MySQL database server. MariaDB is popular for its performance and scalability.
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.
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 reposity, We are good to install
apache2 package using follwing 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, Kinldy use the follwing 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 MariaDB
In order to install MariaDB server on ubuntu, You need to execute the given command for the same.
sudo apt-get install mariadb-server mariadb-client -y
Use the following command as the root user to secure the MariaDB server after the aforementioned packages have been successfully installed.
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.
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.