Introduction
LAMP is an acronym that stands for Linux, Apache, MySQL, and PHP. It refers to a popular open-source technology stack that is widely used for web development and hosting.
Prerequisites
You must following things to complete this tutorial.
- Ubuntu 22.04 LTS up and running.
- Root permission.
- Basic knowledge of linux commands.
- Internet connectivity.
In this post, We will show you how to install LAMP Server on ubuntu 22.04 LTS.
Step 1: Update System
We need to update the ubuntu’s repository and their packages by executing given command.
sudo apt-get update
sudo apt-get upgrade
Step 2: Installing Apache Web Server
To install apache web server we just need to execute the given command that command install and setup the apache web server and service for us.
sudo apt-get install apache2 -y
Step 3: Verify Apache Service
After installation of apache web server we need to make sure apache’s service should up and running, Use the given command for the same.
sudo systemctl status apache2
Step 4: Installing MySQL Database Server
To install MySQL on ubuntu machine, We need to use the given command by default repository available in ubuntu 22.04 LTS version.
sudo apt-get install mysql-server -y
Step 5: Running MySQL Security Script
After installation of MySQL server on ubuntu machine its having some test and user data, To secure MySQL we need to execute the secure script, Use the given command for the same.
sudo mysql_secure_installation
Follow the on-screen instructions to set a root password, remove anonymous users, disable remote root login, and remove test databases.
Step 6: Installing PHP & Modues
PHP package is required to run the PHP based project and PHP module, Execute the given command for the same.
sudo apt-get install php libapache2-mod-php php-mysql php-curl php-gd php-json php-zip php-xml -y
Step 7: Verify PHP Installation
Now we need to verify the apache is working with PHP or not to make sure, We need to use the given steps.
To make info.php.
sudo nano /var/www/html/info.php
Add the following lines to the file:
<?php
phpinfo();
?>
Save and close the file.
Restart Apache:
sudo systemctl restart apache2
Step 8: Access the PHP info
http://IPaddress/info.php
You should see the PHP version and configuration details.
Step 9: Remove the PHP info page
sudo rm /var/www/html/info.php
Conclusion
We have successfully installed and setup LAMP stack on Ubuntu. If you have any questions or issues, please leave a comment below.