Red Hat Server is a set of tutorials, which will help you install and configure a server based on Red Hat Linux or its clones. The tutorials are based on the Rocky Linux 9.5 installation, which is fully compatible with Red Hat and can also be used with CloudLinux, AlmaLinux, EuroLinux, CentOS Stream, MIRACLE Linux, etc.
The first post in this series is dedicated to installing a web server.
1. Installing the Web Server
If the remote server is already running a Red Hat-compatible distribution, and you’ve registered a domain, redirected it to your server, and logged in, you can install one of two web servers: Apache or Nginx. I won’t discuss other web servers, such as Lighttpd and thetpd, as I recommend the first two without reservation.
Log in to the server administrator account:
su -
or
su
using the root password.
Update packages with the command:
dnf upgrade
2A. Installing Apache
Now you can install the Apache server:
dnf install httpd httpd-tools
Checking Apache status:
systemctl status httpd
If the status is disabled:
systemctl enable httpd
If the status indicates it’s not running:
systemctl start httpd
The Apache home page should now be available in your web browser at your server’s IP address. If the domain has already been propagated, you can enter the domain address in your web browser instead of the IP address.
The homepage files have been saved in the default location:
/var/www/http/
The default Apache configuration is available in the directory:
/etc/httpd/conf.d/
You should change the owner of the directory containing the website files:
chown apache:apache /var/www/html -R
And add the hostname:
nano /etc/httpd/conf.d/servername.conf
by entering the line:
ServerName localhost
and reload the Apache server:
systemctl reload httpd
2B. Installing Nginx
Alternatively, you can install the Nginx web server instead of Apache:
dnf install nginx
Checking the Nginx status:
systemctl status nginx
If the status is disabled:
systemctl enable nginx
If the status indicates it is not running:
systemctl start nginx
Change the directory owner:
chown nginx:nginx /usr/share/nginx/html -R
3. If your new website is not accessible from the outside, you have to:
a. open ports 80 and 443 for http and https connections:
firewall-cmd –permanent –zone=public –add-service=http
firewall-cmd –permanent –zone=public –add-service=https
b. reload the firewall:
systemctl reload firewalld
If the web server is working properly, in the next article we will install the PHP interpreter and the MariaDB database system.
