How To Install LAMP Stack on AlmaLinux

Posted on by Neil Golden
Reading Time: 3 minutes

AlmaLinux is an open-source, Linux OS that will replace CentOS since it soon reaches End-of-Life (EOL) and will no longer be supported. Comparing CentOS vs AlmaLinux, you find that AlmaLinux is a one-to-one replacement for CentOS with a longer lifecycle and a simple installation process.

This step-by-step article will teach you how to install the LAMP stack on AlmaLinux. LAMP is an acronym that signifies the collection of open source server software used to support dynamic and static websites. You can follow this tutorial with the appropriate user permissions to get your server up and running.

Here are the LAMP definitions:

  • L - Linux operating system.
  • A - Apache Web Server.
  • M - MySQL or MariaDB database management system (DBMS).
  • P - PHP backend coding language used for maintaining and developing websites.

Configure Apache

It is not necessary to implement an additional repository for installing the LAMP Stack on AlmaLinux since all of the required software is included in the AppStream AlmaLinux repository. Open your terminal and log in as the root user by entering the following command in your terminal.

sudo su -

Install the Apache Web Server by running the following command.

dnf install -y httpd

Once the Apache installation is complete, you will have to start and enable the httpd service.

systemctl start httpd

systemctl enable httpd

In order to confirm that your Apache web server is installed and running correctly, you can check the http service status and if it's listening on the default port (80). Run the following command to check the status of your http service.

service httpd status

If everything is configured correctly, your output will look similar to the below example.

httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor prese>
Active: active (running) since Mon 2023-01-02 01:04:27 EST; 14s ago
Docs: man:httpd.service(8)
Main PID: 49007 (httpd)
Status: "Started, listening on: port 80"

Next, allow HTTP and HTTPS traffic in your firewall using these commands.

firewall-cmd --permanent --zone=public --add-service=http

firewall-cmd --permanent --zone=public --add-service=https

In order to apply the new firewall rules, restart your firewall by using the following command.

firewall-cmd --reload

You have successfully installed the Apache Web Server.

Configure MySQL

For the MySQL installation, the AppStream AlmaLinux repository will be sufficient. Use the following command to install the MySQL database management system quickly.

dnf install -y mysql mysql-server

After the installation is completed, start and enable the mysqld service to run every time system boots up by entering the following commands in your terminal.

systemctl start  mysqld

systemctl enable  mysqld

It is recommended to execute the additional steps to secure your server from malicious users. Enter the following command in your terminal to secure your MySQL database server from frequent attacks.

mysql_secure_installation

You will be prompted with additional configuration steps, create the password for your DBMS and afterward type y to all of the prompted steps. MySQL is successfully and securely installed.

To login, run the following command.

mysql -u root -p

Install PHP 8.0 on AlmaLinux 8

The latest version of PHP for AlmaLinux at the time of publishing is 8.0. To install PHP 8.0. on AlmaLinux, update the system packages by entering the following command.

dnf update

Next, check the available versions of PHP modules on the AppStream AlmaLinux repository.

dnf module list php

The output contains the available PHP versions, in this case, PHP 8.0. Follow the next command to enable the PHP 8.0 module.

dnf module enable php:8.0

Finally, install PHP on your AlmaLinux system with some of the recommended extensions by entering the following command.

dnf install php php-fpm php-zip php-intl php-opcache php-gd php-mbstring php-gd php-xml php-mysqlnd

Test the Installation

Now that the installation of the LAMP stack on AlmaLinux finished, test if Apache, MySQL, and PHP are configured correctly. You can quickly check for a successful installation by checking if the following commands return the respective versions.

Apache

Use this command to check the Apache version.

httpd -v

The following output example shows the version.

Server version: Apache/2.4.53 (AlmaLInux)
   Server built:	  Jul 20 2022 00:00:00

PHP

Here is the command to confirm the PHP version.

php -v

The following is the output example.

PHP 8.0.27 (cli) (built: Jan 5 2023 21:55:55) (NTS gcc x86_64)
   Copyright (c) The PHP Group
   Zend Engine v4.1.8, Copyright (c) Zend Technologies
     	 	   with Zend OPcache v8.0.27, Copyright (c), by Zend Technologies

MySQL

Use the following command to confirm the MySQL version.

mysql --version

Here is an output example.

mysql  Ver 8.0.30 for Linux on x86_64 (Source distribution)

If all of the commands return a similar output as presented above, your LAMP stack is correctly installed and ready to use.

Conclusion

This step-by-step guide walked you through how to install the LAMP stack on AlmaLinux. Following this guide, successfully install Apache Web Server, the MySQL client and software, and PHP version 8.0. Additional considerations include  creating an FTP server and account or installing and configuring LsyncD.

Liquid Web offers VPS Hosting, Cloud Dedicated Servers, and Dedicated Servers for your website hosting needs. With the knowledge of installing the LAMP stack on AlmaLinux, you are one step ahead in hosting your website. Our highly professional support technicians will always be there to assist you with any kind of issue. Contact our sales team and publish your fantastic website online today.

Avatar for Neil Golden

About the Author: Neil Golden

Neil contributed to solving the complex puzzle of evolution for a long time by obtaining his Ph.D. in Archaeology. These days, he digs the Linux servers in his role within the Liquid Web Monitoring Department instead of Paleolithic stone tools in the caves on archaeological sites. Instead of mammoths, he is now hunting for bugs on Linux servers. He has written numerous scientific and technical articles because writing is one of his biggest passions. In his free time, Neil composes music, reads novels, and travels the world.

Latest Articles

Controlling PHP settings with a custom php.ini file

Read Article

How to install Puppet Server on Linux (AlmaLinux)

Read Article

Email security best practices for using SPF, DKIM, and DMARC

Read Article

Linux dos2unix command syntax — removing hidden Windows characters from files

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article