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)

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

When encountering DNS problems, first check the /etc/resolv.conf file to see if the correct nameserver is configured; secondly, you can manually add public DNS such as 8.8.8.8 for testing; then use nslookup and dig commands to verify whether DNS resolution is normal. If these tools are not installed, you can first install the dnsutils or bind-utils package; then check the systemd-resolved service status and configuration file /etc/systemd/resolved.conf, and set DNS and FallbackDNS as needed and restart the service; finally check the network interface status and firewall rules, confirm that port 53 is not

If you find that the server is running slowly or the memory usage is too high, you should check the cause before operating. First, you need to check the system resource usage, use top, htop, free-h, iostat, ss-antp and other commands to check CPU, memory, disk I/O and network connections; secondly, analyze specific process problems, and track the behavior of high-occupancy processes through tools such as ps, jstack, strace; then check logs and monitoring data, view OOM records, exception requests, slow queries and other clues; finally, targeted processing is carried out based on common reasons such as memory leaks, connection pool exhaustion, cache failure storms, and timing task conflicts, optimize code logic, set up a timeout retry mechanism, add current limit fuses, and regularly pressure measurement and evaluation resources.

As a system administrator, you may find yourself (today or in the future) working in an environment where Windows and Linux coexist. It is no secret that some big companies prefer (or have to) run some of their production services in Windows boxes an

Frankly speaking, I cannot recall the last time I used a PC with a CD/DVD drive. This is thanks to the ever-evolving tech industry which has seen optical disks replaced by USB drives and other smaller and compact storage media that offer more storage

In Linux systems, 1. Use ipa or hostname-I command to view private IP; 2. Use curlifconfig.me or curlipinfo.io/ip to obtain public IP; 3. The desktop version can view private IP through system settings, and the browser can access specific websites to view public IP; 4. Common commands can be set as aliases for quick call. These methods are simple and practical, suitable for IP viewing needs in different scenarios.

Built on Chrome’s V8 engine, Node.JS is an open-source, event-driven JavaScript runtime environment crafted for building scalable applications and backend APIs. NodeJS is known for being lightweight and efficient due to its non-blocking I/O model and

Data replication is the process of copying your data across multiple servers to improve data availability and enhance the reliability and performance of an application. In MySQL replication, data is copied from a database from the master server to ot
