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

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

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

Gogo is a remarkable tool to bookmark directories inside your Linux shell. It helps you create shortcuts for long and complex paths in Linux. This way, you no longer need to type or memorize lengthy paths on Linux.For example, if there's a directory

PPA is an important tool for Ubuntu users to expand their software sources. 1. When searching for PPA, you should visit Launchpad.net, confirm the official PPA in the project official website or document, and read the description and user comments to ensure its security and maintenance status; 2. Add PPA to use the terminal command sudoadd-apt-repositoryppa:/, and then run sudoaptupdate to update the package list; 3. Manage PPAs to view the added list through the grep command, use the --remove parameter to remove or manually delete the .list file to avoid problems caused by incompatibility or stopping updates; 4. Use PPA to weigh the necessity and prioritize the situations that the official does not provide or require a new version of the software.

LXD is described as the next-generation container and virtual machine manager that offers an immersive for Linux systems running inside containers or as virtual machines. It provides images for an inordinate number of Linux distributions with support

How to quickly generate test files of a specified size? It can be achieved using command line tools or graphical software. On Windows, you can use fsutilfilecreatenew file name size to generate a file with a specified byte; macOS/Linux can use ddif=/dev/zeroof=filebs=1Mcount=100 to generate real data files, or use truncate-s100M files to quickly create sparse files. If you are not familiar with the command line, you can choose FSUtilGUI, DummyFileGenerator and other tool software. Notes include: pay attention to file system limitations (such as FAT32 file size upper limit), avoid overwriting existing files, and some programs may

The key to installing dual systems in Linux and Windows is partitioning and boot settings. 1. Preparation includes backing up data and compressing existing partitions to make space; 2. Use Ventoy or Rufus to make Linux boot USB disk, recommend Ubuntu; 3. Select "Coexist with other systems" or manually partition during installation (/at least 20GB, /home remaining space, swap optional); 4. Check the installation of third-party drivers to avoid hardware problems; 5. If you do not enter the Grub boot menu after installation, you can use boot-repair to repair the boot or adjust the BIOS startup sequence. As long as the steps are clear and the operation is done properly, the whole process is not complicated.

Node Version Manager (NVM) is a simple bash script that helps manage multiple Node.js versions on your Linux system. It enables you to install various Node.js versions, view available versions for installation, and check already installed versions.NV
