How to Install a Web Server on AlmaLinux
AlmaLinux is a free and open-source Linux distribution that serves as a replacement for CentOS. If you’re looking to set up a web server on your AlmaLinux system, you’ve come to the right place. In this guide, we’ll walk you through the process of installing and configuring a web server on AlmaLinux. Let’s get started!
Step 1: Update System Packages
Before we begin installing the web server, it’s important to update the system packages to ensure we have the latest versions. You can do this by running the following commands in your terminal:
sudo dnf update
Wait for the package update process to complete before moving on to the next step.
Step 2: Install Apache Web Server
Apache is one of the most popular web servers in the world, and it’s easy to install on AlmaLinux. To install Apache, run the following command:
sudo dnf install httpd
After the installation is complete, start the Apache service and enable it to run on system boot with the following commands:
sudo systemctl start httpd
sudo systemctl enable httpd
You can now access your Apache web server by entering your server’s IP address in your web browser.
Step 3: Configure Firewall
It’s important to configure the firewall to allow traffic on port 80, which is the default port for web traffic. You can do this by running the following command:
sudo firewall-cmd --zone=public --add-service=http --permanent
After adding the rule, reload the firewall to apply the changes:
sudo firewall-cmd --reload
Your firewall is now configured to allow web traffic on port 80.
Step 4: Install MariaDB
MariaDB is a popular open-source database management system that works seamlessly with Apache. To install MariaDB, run the following command:
sudo dnf install mariadb-server
After the installation is complete, start the MariaDB service and enable it to run on system boot:
sudo systemctl start mariadb
sudo systemctl enable mariadb
You can now secure your MariaDB installation by running the following command:
sudo mysql_secure_installation
Follow the on-screen prompts to configure MariaDB security settings.
Step 5: Install PHP
PHP is a server-side scripting language that is used to power dynamic websites. To install PHP on your AlmaLinux system, run the following command:
sudo dnf install php php-mysqlnd
After the installation is complete, restart the Apache service to load the PHP module:
sudo systemctl restart httpd
Your web server is now configured with Apache, MariaDB, and PHP. You can now host your websites and applications on your AlmaLinux system.
Setting up a web server on AlmaLinux is a straightforward process that can be completed in just a few steps. By following this guide, you’ll have a powerful web server up and running in no time. Happy hosting!