A LAMP is a group of software that provides a fully functional environment to host websites or PHP applications on the internet. It is open-source and one of the most popular stacks to host any kind of website. A LAMP is an acronym of the four software, Linux Operating System, Apache HTTP Server, MySQL or MariaDB database management system, and PHP programming language.
In this post, we will show you how to install the LAMP stack on AlmaLinux 8.
Table of Contents
Prerequisites
- An AlmaLinux 8 VPS (we’ll be using our SSD 2 VPS hosting plan)
- Access to the root user account (or access to an admin account with root privileges)
Log in to the Server & Update the Server OS Packages
First, log in to your AlmaLinux 8 server via SSH as the root user:
ssh root@IP_Address -p Port_number
You will need to replace ‘IP_Address’ and ‘Port_number’ with your server’s respective IP address and SSH port number. Additionally, replace ‘root’ with the username of the admin account if necessary.
Before starting, you have to make sure that all AlmaLinux OS packages installed on the server are up to date. You can do this by running the following commands:
dnf update -y
Install Apache Web Server
First, you can install the Apache webserver using the following command:
dnf install httpd httpd-tools -y
After installing Apache, start the Apache service and enable it to start at system reboot:
systemctl start httpd systemctl enable httpd
Now, open your web browser and type the URL http://your-server-ip. You should see your Apache web server test page in the following screenshot:
Install MariaDB Database Server
You can install the MariaDB database server with the following command:
dnf install mariadb-server mariadb -y
Once the MariaDB is installed, start the MariaDB service and enable it to start at system reboot:
systemctl start mariadb systemctl enable mariadb
Next, run the following command to set the MariaDB root password:
mysql_secure_installation
Answer the following questions to set a root password and secure the MariaDB installation:
- Set root password? [Y/n] y - Remove anonymous users? [Y/n] y - Disallow root login remotely? [Y/n] y - Remove test database and access to it? [Y/n] y - Reload privilege tables now? [Y/n] y
Install PHP
Next, you can install PHP with other most commonly used extensions by running the following command:
dnf install php-mysqlnd php-dom php-simplexml php-xml php-curl php-exif php-ftp php-gd php-iconv php-json php-mbstring php-posix -y
After installing PHP, restart the Apache service to apply the changes:
systemctl restart httpd
Verify PHP Installation
In order to verify the PHP installation, create a new info.php file:
nano /var/www/html/info.php
Add the following lines:
<?php phpinfo (); ?>
Save and close the file when you are finished.
Now, open your web browser and access the info.php file using the URL http://your-server-ip/info.php. You should see the following page:
Congratulations! You have successfully installed LAMP (Apache, MariaDB, and PHP) Stack on your AlmaLinux 8 system.
Of course, you don’t have to install LAMP Stack if you use one of our LAMP Hosting services, in which case you can simply ask our expert Linux admins to install LAMP Stack on AlmaLinux 8, for you. They are available 24/7 and will take care of your request immediately.
PS. If you liked this post on how to install LAMP Stack on AlmaLinux 8, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.