Below is the procedure to install LAMP Server on Ubuntu Server.
Contents
What is LAMP?
In order to install a web server on your Linux Server, you need to install applications into your server. These applications are called LAMP, which is an abbreviation for four applications.
L = Linux
A = Apache
M = MySQL
P = PHP
How to Install LAMP?
As you must already have Linux Installed. You can use any distribution of Linux Kernal, it could be Ubuntu, Opensuse, Debian, Oracle Linux, or anything. I will be using Ubuntu 20.04 to install LAMP. Let us install all 4 applications of LAMP.
1. Update Ubuntu Server
To install Ubuntu you can follow the blog here You can do this either on a physical server or VM Server.
Once Ubuntu is installed you can now update the Ubuntu Server. Open SSH or Putty and first update and upgrade the packages by running the below command
sudo apt update -y && sudo apt upgrade -y
2. Install LAMP on Ubuntu
You need to make Ubuntu a Web server. In order to install the lamp, we will use the below steps.
Install Apache2
Install apache2 by using the below command
sudo apt install apache2 -y
Now Enable and Start the apache2 service
systemctl start apache2 && systemctl enable apache2
Now check the status of the service
systemctl status apache2
Let us now check the version of apache2 to validate
apache2 -v
great if you see the version information you are done.
In case the firewall is enabled you need to open HTTP and HTTPS ports to this server. just run the below commands for the firewall
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload
Now you can open the browser and validate that the webserver is ready with apache2.
http://<serverip> in my case it is https://lamp.syncbricks.com
Now let us install other packages
MySQL / MariaDB
MySQL is the Database Server Installation. You need to first install the database Server and Client both will be installed using the below command.
sudo apt install mariadb-server mariadb-client -y
Now let us follow the same step as mentioned in apache2. Enable and Start the service and then check the version and status of the service
sudo systemctl start mariadb && sudo systemctl enable mariadb
sudo systemctl status mariadb
Before we proceed further let us now secure the installation by running the below command
sudo mysql_secure_installation
You will need to enter when the password is promoted as there is no password. THen you have to set the root password. disallow remote and anonymous access and remove the test database.
PHP Installation
Installing PHP and its related extensions if needed, I will install php7.4 as it is supported by various web applications and websites, though PHP 8 is also available I will stick to 7.4 for the time being.
sudo apt install php php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath
Now let us verify the PHP Installation by checking its version
php --version
Done
Your Server is now Web Server. All required applications are installed.You can now install any Web Application in Web Server, some of them are below
if you have any feedback, please don’t hesitate to share.