LAMP stack is a group of software or resources for the web application. LAMP stands respectively for Linux, Apache, MariaDB or MySQL, and PHP. This software is open source and gives power to a huge number of websites.
In this tutorial, I will use MariaDB as a replacement for MySQL; typically, MySQL is included in the LAMP stack. For installations of a LAMP stack on Linux, you will need Ubuntu or Debian’s latest distribution.
I will use Debian 10 to install LAMP stack, but the same instructions you can apply on Ubuntu 18.04 or the latest Ubuntu 20.04, so let’s start 😃.
Table Of Contents
- 1 STEP – 1. Installing Apache Server
- 2 STEP – 2. Installing MariaDB Database
- 3 STEP – 3. Installing PHP 7.4x
- 4 FAQs about LAMP installation
- 4.1 How do I install PHP?
- 4.2 How do you install a LAMP stack?
- 4.3 How do I install a lamp in Windows 10?
- 4.4 How do I check if a lamp is installed Ubuntu?
- 4.5 What is meant by the LAMP stack?
- 4.6 What can you do with a LAMP server?
- 4.7 How do I know if PHP is installed?
- 4.8 Do you need to install PHP?
- 4.9 How do I start a lamp in Linux?
- 4.10 Which is better xampp or lamp?
- 4.11 Is lamp a framework?
- 5 Summary
STEP – 1. Installing Apache Server
Apache server is one of the widely used and very popular web servers. Apache is easy to use, and you can find a huge amount of documentation and tutorials over the Internet.
sudo apt update
sudo apt install apache2
This apache server installation process will require sudo permission. When you execute the Apache server’s command above, the image showed, “Do you want to continue? [Y/n]” Press Y and hit ENTER.
Now check, is the Apache server working or not? There are two simple methods to check apache status, first execute the following command:
sudo service apache2 status
Or you can type your IP address on the new browser tab in this format
If the second method doesn’t work or, as above in the image shown, the apache server page doesn’t work, and then there is probably an issue with firewall rules.
The best practice for setting up firewall rules is manually checking up the security rules on the web-server or server instance’s setting.
STEP – 2. Installing MariaDB Database
Our server is running, and now what we need, storage that stores data in a structured table format. Obviously, table format data is elementary to manage, and most of the websites and web developers prefer to use table structured storage.
MariaDB is a forked version of the MySQL database developed by Oracle. Debian and Ubuntu’s latest version can be easily configurable with MariaDB.
For installing MariaDB for our LAMP stack, execute the following command:
sudo apt install default-mysql-server
sudo apt install mariadb-server
When we execute the command, the machine will prompt you to continue or not; Press Y and hit ENTER. This process will take less than 20 seconds, and after, we will go for the next step.
Now, our MariaDB installation was successful, and we need to secure it. MariaDB happens without any password protection, and there will an anonymous user for a test database, so we need to remove that user and the test database.
For securing the MariaDB execute the following command:
As you can see in the image above, when we execute the command for securing MariaDB, the instance prompts us to enter the root password. Still, when we install a database for your clarity, there is no password, so hit ENTER.
Now the prompt is for the set new root password, Press Y and hit ENTER, and then it will ask to enter a new password when you enter then the second time will ask for Re-enter new password. To re-enter the password and hit the ENTER key.
The next prompt will be removing anonymous users, so definitely, Press Y and hit the ENTER button. As you can see in the image above, the MariaDB installation adds an anonymous user so anyone can log into the database without having a user account. So, the best practice is that remove anonymous users.
The next prompt is “Disallow root login remotely?” That means if you enable this feature, then you can access your database from any network or location. Still, it could be harmful to your projects or websites because hackers can inject malicious code or even hijack your websites. So, Disallow the remote login by pressing Y and then hit ENTER.
The next prompt is the “Remove test database?” Definitely press Y and hit ENTER for removing the test database that has no password. This test database comes during the MariaDB installation.
Next and last prompt to reloading the privilege, Press Y and hit ENTER to reload all the privileges. These changes take immediate effect and make our database secured.
SIMPLIFY THE INSTALLATION:
Execute command > Hit enter for current root password > Press Y and hit ENTER for new password > Set New Password > Re-enter New Password > Press Y and Hit ENTER for delete anonymous users > Press Y and Hit ENTER for Disallow remote login > Press Y and Hit ENTER for Delete test Database > Press Y and Hit ENTER for Reload Privileges.
Those are the simple steps of installations of MariaDB for the LAMP stack on Ubuntu and Debian server. After database installation, you can create a new database for every new project. You can also create your database for a WordPress website, and even you can create multiple databases and install various WordPress websites on a single server.
Next to installation steps for the latest PHP.
STEP – 3. Installing PHP 7.4x
PHP is a popular and widely used scripting language in the world. PHP – Hypertext Preprocessor is very important to run a web application or website. You know the popular platform WordPress, which is based on PHP. PHP script runs in the backend and dynamically shows the database’s data in the frontend of any application or website.
We will install the latest version of PHP, so our application and projects would be secured from hackers. For installing the latest version of PHP 7.4x, use the following commands:
Must Read:- How To Install Latest PHP 8.0.x On Linux System?
#Update System and Reboot:
sudo apt update
sudo apt upgrade -y && sudo reboot
#Add Sury PHP PPA Repository and key data:
sudo apt -y install lsb-release apt-transport-https ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
#Install latest PHP 7.4x:
sudo apt update
sudo apt install php7.4
#Install latest PHP modules:
sudo apt install php7.4-common php7.4-cli php7.4-bz2 php7.4-curl php7.4-gd php7.4-intl php7.4-json php7.4-readline php7.4-xml php7.4-zip php7.4-fpm php7.4-bcmath php7.4-mbstring php7.4-imagick
#Install Apache with PHP modules:
sudo apt install apache2 php7.4 libapache2-mod-php7.4 php7.4-common php7.4-mbstring php7.4-xmlrpc php7.4-soap php7.4-gd php7.4-xml php7.4-intl php7.4-mysql php7.4-cli php7.4-ldap php7.4-zip php7.4-curl
#Enable PHP FPM services:
a2enmod proxy_fcgi setenvif
#Restart or Reload Apache server:
systemctl restart apache2
systemctl reload apache2
#checking PHP version:
PHP installation has also been done, and now you can deploy any web application or website using these resources.
FAQs about LAMP installation
How do I install PHP?
Use the following commands for installing the latest PHP
$ sudo apt install php7.4
How do you install a LAMP stack?
How do I install a lamp in Windows 10?
You can install a LAMP stack on Windows 10 using Bitnami Xaamp or LAMP software.
How do I check if a lamp is installed Ubuntu?
Check Apache status, MySQL status, and PHP status individually in terminal using these commands, respectively:
$ services apace2 status
$ php -value
What is meant by the LAMP stack?
LAMP stack is a group of opensource software and L stand for Linux, A stand for Apache, M stands for MySQL, and P stand for PHP.
What can you do with a LAMP server?
LAMP server is very useful, it is a group of software that gives power to your Web application project or website projects.
How do I know if PHP is installed?
Open Terminal and type
$ php -value, it will show you the PHP versions if installed.
Do you need to install PHP?
For LAMP stack, yes need to download PHP and also for Web development.
How do I start a lamp in Linux?
When you install one by one the LAMP stack’s software, it automatically start.
Which is better xampp or lamp?
XAMPP and LAMP are both useful stacks; XAMPP includes more software than LAMP.
Is lamp a framework?
LAMP is a group of software.
LAMP stack is beneficial when we work on multiple projects and we have a single server. It is a powerful group of software that makes it easier to develop websites and web applications. If you want to install multiple WordPress sites on a single server, then the LAMP stack would be helpful.
You can use these simple steps to install the LAMP stack in any Ubuntu system or Debian system, and it will work perfectly. By chance, if you have encountered an error, please put your comments in the box. We are willing to share good knowledge with everyone.
Thank you! If you think this article would be helpful for your close one, please share 💚.