LAMP is a popular open-source software stack that is mostly used for testing and hosting web applications. It’s an acronym for Linux Apache MariaDB / MySQL and PHP. It compromises a web server ( Apache ), a database server ( MariaDB or MySQL ), and the PHP scripting language which supports dynamic web pages written in PHP. In this guide, we feature the installation of LAMP on AlmaLinux 8

Step 1: Upgrade system packages

Before we being the installation, it’s always to upgrade the system packages to their latest versions. Upgrading also has the effect of rebuilding the system’s repository cache. Therefore, to run a system update, execute:

$ sudo dnf update

Step 2: Install Apache webserver

The first component we are going to install is the Apache webserver. To install Apache on AlmaLinux 8 alongside other tools and dependencies run:

$ sudo dnf install httpd

How to install LAMP stack on AlmaLinux 8 centos linux

Once the installation is done, we need to start and enable Apache to fire up every time we start or boot into AlmaLinux.

To enable Apache, first, simply run:

$ sudo systemctl enable httpd

Then run the command below to start the Apache service.

$ sudo systemctl start httpd

How to install LAMP stack on AlmaLinux 8 centos linux

We need to confirm that Apache is running without any errors. To verify this, we will run the command:

$ sudo systemctl status httpd

You can also confirm the status of Apache from a web browser. But first, we need to allow HTTP traffic across the firewall. Simply run the command shown to allow HTTP traffic.

$ sudo firewall-cmd --add-service=http --permanent

Then reload the firewall to the changes to take effect.

$ sudo firewall-cmd --reload

How to install LAMP stack on AlmaLinux 8 centos linux

Great! Now simply launch your preferred web browser and visit the server’s IP as shown. This displays the default Apache test page.Advertisement

http://server-ip

How to install LAMP stack on AlmaLinux 8 centos linux

Step 3: Install MariaDB database server

MariaDB is an open-source database server that is a fork of MySQL. It provides numerous features such as storage engines, faster replication, and enhanced security which makes it more popular between the two. To install MariaDB, run the command:

$ sudo dnf install mariadb-server mariadb

How to install LAMP stack on AlmaLinux 8 centos linux

Once done, enable MariaDB so that every time you boot into AlmaLinux, MariaDB starts automatically.

$ sudo systemctl enable mariadb

Then start the service.

$ sudo systemctl start mariadb

How to install LAMP stack on AlmaLinux 8 centos linux

MariaDB settings, by default, are weak and this poses potential security risks such as breaches by hackers. To secure the database server, run the mysql_secure_installation script

$ sudo mysql_secure_installation

You are first required to set the Root password for authentication purposes.

How to install LAMP stack on AlmaLinux 8 centos linux

For the remaining prompts, type ‘Y’ to apply the recommended settings which include removing the default anonymous user, disallowing remote login by the root user, and removing the test database which can be leveraged by attackers to gain entry to the database server.

How to install LAMP stack on AlmaLinux 8 centos linux

To log in to MariaDB, issue the command:

$ sudo mysql -u root -p

How to install LAMP stack on AlmaLinux 8 centos linux

Step 4: Install the latest PHP version

PHP is a popular open-source scripting language used in the development of dynamic websites and is core in the development of blogging platforms such as Drupal and WordPress. By default, AlmaLinux repositories provide PHP 7.4 by default. However, a newer version is available – PHP 8.0

Therefore, we will install the latest PHP release which is PHP 8.0. Since this is not offered in the official repositories, we will enable Remi repository which is a 3rd party YUM repository that provides PHP stacks,

To enable the Remi repository just issue the command:

$ sudo dnf install http://rpms.remirepo.net/enterprise/remi-release-8.rpm

How to install LAMP stack on AlmaLinux 8 centos linux

To get a glance at the available PHP modules, run:

$ sudo dnf module list php

How to install LAMP stack on AlmaLinux 8 centos linux

The default module provided is PHP 7.2. However, we need to enable the latest module which will provide PHP 8.0. With this in mind, we will reset the default module.

$ sudo dnf module reset php

Next, enable the latest PHP Remi module

$ sudo dnf module enable php:remi-8.0

How to install LAMP stack on AlmaLinux 8 centos linux

With the latest module enabled, proceed and install php 8.0 and the preferred php extensions as illustrated.

$ sudo dnf install php php-fpm php-curl php-cli php-gd

How to install LAMP stack on AlmaLinux 8 centos linux

Finally, confirm the version of PHP installed.

$ php -v

How to install LAMP stack on AlmaLinux 8 centos linux

You can also test PHP from a web browser by first creating a simple php file in the webroot directory as shown.

$ sudo vim /var/www/html/info.php

Paste the following lines and save the file.


Then restart the Apache webserver

$ sudo systemctl restart httpd

Once again, head over to your browser and browse the URL shown.

http://server-IP/info.php

The webpage showing details of the PHP version installed including detailed information about the PHP extensions will be displayed.

How to install LAMP stack on AlmaLinux 8 centos linux

Conclusion

And there you go ladies and gentlemen. We have wrapped up the installation of the LAMP stack on AlmaLinux 8.4.