LAMP is a popular hosting stack used for developing and testing web applications. It’s an acronym for Linux, Apache, MariaDB, & PHP.
Apache is an open-source and widely used web server. MariaDB is an open-source relational database server that stores data in tables inside databases, and PHP is a server-side scripting language used for developing dynamic web pages.
In this walkthrough, we will demonstrate the installation of the LAMP stack in AlmaLinux.
Step 1: Install Apache in AlmaLinux
We start off with the installation of the Apache webserver. The Apache httpd package is hosted on the AppStream repository. As such, you can install Apache using the DNF package manager as follows:
$ sudo dnf install -y @httpd
When the installation of Apache is done, proceed and start the Apache service as shown.
$ sudo systemctl start httpd
You would also want to enable the Apache webserver to start when the system is powered on or upon a reboot. Therefore, enable the Apache service.
$ sudo systemctl enable httpd
To be sure that Apache is running, run the command:
$ sudo systemctl status httpd
The output is a clear indication that Apache is running as expected.
We can also test that Apache is active by browsing the server’s IP or domain name. But first, if you have Firewalld enabled, you need to allow HTTP traffic across the firewall.
$ sudo firewall-cmd --permanent --zone=public --add-service=http
To apply the changes, reload the firewall.
$ sudo firewall-cmd --reload
You can now proceed to browse the server’s IP address as shown.
http://server-ip-address OR http://your-domain.com
The Apache welcome page will come to view, a confirmation that the webserver was successfully set up.
Step 2: Install MariaDB in AlmaLinux
Moving on, we are going to install MariaDB – is a relational database management system (RDBMS) which is a fork of MySQL. MariaDB is also available from the AppStream repository. You can list the available versions of MariaDB by running the following command
$ sudo dnf module list mariadb
From the output, the default version is MariaDB 10.3. However, we will install 10.5 which is the latest one in the repository. For this to happen, reset the MariaDB module as follows.
$ sudo dnf module reset mariadb
Then install the latest MariaDB version using the command:
$ sudo dnf module install mariadb:10.5
Once complete, be sure to start the MariaDB service.
$ sudo systemctl start mariadb
Then enable MariaDB to start every time the system is booted or upon a reboot.
$ sudo systemctl enable mariadb
Just to confirm that the relational database server is up and running, execute:
$ sudo systemctl status mariadb
MariaDB’s default settings are weak and pose a potential security risk to the server. As such, we will go a step further and harden MariaDB. Run the script shown.
$ sudo mysql_secure_installation
You will be taken through a couple of prompts. Be sure to first set the root password.
For the remainder of the prompts, answer 'Y'
to tweak it to the recommended settings. This involves removing anonymous users, blocking remote root login, and removing the test database.
To log in to your database server run the command.
$ sudo mysql -u root -p
Step 3: Install PHP 8 in AlmaLinux
The final component of the LAMP stack that we are going to install is PHP. This is a server-side scripting language for the development of dynamic web applications.
To check the PHP versions available in the AppStream repository, run:
$ sudo dnf module list php
The latest version offered by AppStream repo is PHP 7.4.
However, if you wish to install the very latest version of PHP, you need to install the Remi repository. This is a third-party repository that provides the latest PHP versions.
Install Remi repository on AlmaLinux as follows:
$ sudo dnf install http://rpms.remirepo.net/enterprise/remi-release-8.rpm
Once again, list the PHP modules offered and this time, you will get the Remi repository on the list with the PHP modules offered.
$ sudo dnf module list php
At the time of writing this guide, the latest PHP version is PHP 8.1 which is a Release Candidate. This is the equivalent of a Beta version and should only be used for testing purposes and not production.
To install the latest PHP module, reset the default PHP module and enable PHP 8.1 module as follows.
$ sudo dnf module reset php $ sudo dnf module enable php:remi-8.1
Finally, install PHP and other PHP modules of your preference as shown.
$ sudo dnf install php php-common php-cli php-mbstring php-xml php-zip php-mysqlnd php-opcache php-curl php-intl php-gd
When the installation is complete, verify the version of PHP installed.
$ php -v
In addition to that, you can test PHP on the browser by first creating a test PHP file as shown.
$ sudo vim /var/www/html/info.php
Next, paste the following PHP files.
<?php phpinfo(); ?>
Save the changes and exit the file. Restart Apache webserver.
$ sudo systemctl restart httpd
Then browse the URL shown.
http://server-ip/info.php OR http://your-domain.com/info.php
This should direct you to the PHP info page indicating the version of PHP installed among other details.
And this concludes this tutorial on the installation of the LAMP stack on AlmaLinux. You can now start hosting Apache Virtual Hosts to run your web applications and secure your Apache with HTTPS.
The above is the detailed content of How to Install LAMP Stack in AlmaLinux 8.4. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

While writing program files or normal text files, programmers and writers sometimes want to know the difference between two files or two versions of the same file. When you compare two computer files on Linux, the difference between their contents is

There are three ways to create empty files in the command line: First, the simplest and safest use of the touch command, which is suitable for debugging scripts or placeholder files; Second, it is quickly created through > redirection but will clear existing content, which is suitable for initializing log files; Third, use echo"> file name to create a file with an empty string, or use echo-n""> file name to avoid line breaks. These three methods have their own applicable scenarios, and choosing the right method can help you complete the task more efficiently.

Linux's cost of ownership is usually lower than Windows. 1) Linux does not require license fees, saving a lot of costs, while Windows requires purchasing a license. 2) Linux has low hardware requirements and can extend the service life of the device. 3) The Linux community provides free support to reduce maintenance costs. 4) Linux is highly secure and reduces productivity losses. 5) The Linux learning curve is steep, but Windows is easier to use. The choice should be based on specific needs and budget.

Are you looking for good software to write mathematical equations? If so, this article provides the top 5 equation editors that you can easily install on your favorite Linux distribution.In addition to being compatible with different types of mathema

dutree is a free, open-source, fast command-line tool for analyzing disk usage, written in the Rust programming language. It was created by combining durep (disk usage reporter) and tree (list directory content in tree-like format) command-line tools

ifconfig in short “interface configuration” utility for system/network administration in Unix/Linux operating systems to configure, manage, and query network interface parameters via command-line interface or in a system configuration scripts

Eclipse is a free integrated development environment (IDE) that programmers around the world use to write software, primarily in Java, but also in other major programming languages using Eclipse plugins.The latest release of Eclipse IDE 2023?06 does

Linux administrators should be familiar with the command-line environment. Since GUI (Graphical User Interface) mode in Linux servers is not commonly installed.SSH may be the most popular protocol to enable Linux administrators to manage the servers
