Table of Contents
This tip is about the how to install and configure Apache on Almalinux 8 / Rocky Linux 8. So read this free guide, How to install and configure Apache on Almalinux 8 / Rocky Linux 8. If you have query related to same article you may contact us.
How to install and configure Apache on Almalinux 8 / Rocky Linux 8 – Guide
Let’s take a look at the steps required to download, install, and run Apache on AlmaLinux 8 / Rocky Linux 8. If you’ve done similar installations on CentOS 8 or Oracle Linux 8, you’ll find the relatable steps. Both Rocky Linux / AlmaLinux 8 Linux distributions aim to replace the collapse of CentOS 8, whose direction has been taken.
prerequisites
Recommended OS: Rocky Linux 8. +.
User account: A user account with sudo or root access.
Update operating system
Update your Rocky Linux operating system to ensure all existing packages are up To date:
sudo update dnf –refresh -y
O tutorial will be using the sudo command and assuming you have sudo status.
To check the status of sudo on your account:
sudo whoami
Example output showing sudo status:
[joshua@rockylinux ~]$ sudo whoamiroot
Per up an existing or new sudo account, visit our tutorial about How to Add a user to Sudoers on Rocky Linux.
To use the root account, use the following command with the root password to login.
su
Install Apache (HTTPD)
Apache, by default, is in the Rocky Linux application stream. This is more practical for most users as it is very stable and secure. To install Apache, open your terminal and run the following command:
sudo dnf install httpd
Type “Y,” then press “ENTER KEY” to continue.
Then, by default, Apache (HTTPD) is disabled and not enabled. First, start the service.
sudo systemctl enable httpd –now
Example output if successful:
Symbolic link created /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Verify that HTTPD is running correctly using the following systemctl command:
systemctl status httpd
Configure firewall rules
It does not automatically add firewall rules to default ports 80 or 443 when installing Apache. Before proceeding, you must define the following rules; it will depend on which ports you will be using, but all options are listed.
Open port 80 or HTTP:
sudo firewall-cmd –permanent –zone = public –add-service = http
Open port 443 or HTTPS:
sudo firewall-cmd –permanent –zone = public –add-service = https
Reload the firewall for the changes to take effect
sudo firewall-cmd –reload
Alternatively, it is ideal to set SELinux permissions globally for your Apache server.
sudo setsebool -P httpd_unified 1
The command will update the SELinux Boolean values and the -P flag to update the boot time value, making the change persistent across system reboots. In general, httpd_unified is the boolean value that will instruct SELinux to treat all Apache processes (HTTPD) as the same type.
Check the Apache web server (HTTPD)
Now that you’ve installed and configured it, it’s time to test to see if the HTTPD service is accessible and working correctly by requesting a page.
You can go to Apache’s default landing page to verify that the software works correctly via your server’s IP address. To find out, if you don’t know, use the following command below:
hostname -I
You should get back the server’s internal IP address as an example:
### EXAMPLE ONLY ### 192.168.50.15
You can get 2-3 results. Try each one until you find the correct IP address.
If you need your public (external) IP address, use the following command:
curl -4 icanhazip.com
It may be necessary to install the CURL package if it is missing. To do this, run the following command:
sudo dnf install curl -y
Once you have the IP address of your servers, open up your favorite internet browser and type the following:
http: // your_server_ip
Congratulations, you have installed the Apache web server (HTTPD) and it is currently working.
Final note
I hope you like the guide How to install and configure Apache on Almalinux 8 / Rocky Linux 8. In case if you have any query regards this article you may ask us. Also, please share your love by sharing this article with your friends.