How To Install LAMP Stack on Linux Mint 21
In this tutorial, we will show you how to install LAMP Stack on Linux Mint 21. For those of you who didn’t know, LAMP is a short name that stands for Linux, Apache, MySQL, and PHP. Developers need a combination of these open-source software to do developments on their local machines before their websites go live. Apache is a web server, MySQL is for databases and PHP is the language used for programming. From multi-layered content management systems to social networking portals supporting millions of users, the LAMP provides a stable foundation for some of the largest web applications
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of LAMP Stack on Linux Mint 21 (Vanessa).
Prerequisites
- A server running one of the following operating systems: Linux Mint 21 (Vanessa).
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install LAMP Stack on Linux Mint 21 Vanessa
Step 1. Before running the tutorial below, it’s important to make sure your system is up to date by running the following apt
commands in the terminal:
sudo apt update sudo apt install software-properties-common apt-transport-https wget ca-certificates gnupg2
Step 2. Installing the LAMP Server.
By default, LAMP Stack is available on the Linux Mint 21 base repository. Now we install the LAMP Stack packages using the following command below:
sudo apt install lamp-server^
When prompted with ‘do you want to continue’ press ‘Enter’ to continue the installation.
Step 3. Testing Apache Web Server.
Apache is web server of the LAMP stack and once installed to confirm the installation run the following in the terminal:
sudo systemctl status apache2
In addition, you can check the installation confirmation from the browser at http://localhost
or http://your-IP-address
, You will get the default Apache server page:
Step 4. Testing PHP.
To test and check if PHP works correctly, first make a file named phpinfo.php
in /var/www/htm
l directory:
nano /var/www/html/phpinfo.php
Copy the below script and paste it into your file:
<?php phpinfo(); ?>
Save and close the file, then restart the Apache service to ensure that the changes take effect before testing PHP:
sudo systemctl restart apache2
Once is done now open up your browser and enter the following:
http://localhost/phpinfo.php
You should see something like this:
Step 5. Configure MySQL.
By default, MySQL is not hardened. You can secure MySQL using the mysql_secure_installation
script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MySQL:
mysql_secure_installation
Step 6. Configure Firewall
After installing LAMP it is necessary to modify UFW firewall rules to open HTTP and HTTPS ports. Run the following command:
sudo ufw allow 'Apache Full' sudo ufw reload
Congratulations! You have successfully installed LAMP. Thanks for using this tutorial for installing the latest version of the LAMP (Apache, MariaDB, and PHP) on the Linux Mint system. For additional help or useful information, we recommend you check the official Linux Mint website.