Virtual Hosts configuration in AlmaLinux 8.8

Hello everyone… I’m new to server config and on a steep learning curve! Trying to configure AlmaLinux 8.8 VirtualHosts for 4 websites on 1 IP Address…However only 1 site works (the 1st listed in NameVirtualHost), and 3 sites are Not Found…

#httpd –t returns:
[Thu Oct 31 16:20:00.796416 2024] [so:warn] [pid 1364850:tid 139855614191936] AH01574: module rewrite_module is already loaded, skipping
Syntax OK

I’ve double-checked /etc/httpd/conf.d/*.conf files and all 4 appear ok… and namei –v lists the dirs/file path but no symlinks… so please may i ask:

  1. Do I need to enable the Symlinks using the command ln -s [target] [symlink]?

  2. And if so, should [target] be to a website’s homepage file or the directory or where do i run the ln command from?

  3. And should i configure Soft or Hard Symlinks?

  4. Also do i need to edit /etc/hosts and /etc/hostname?
    (As I can see the domain-name we set-up the server with is listed in both files).

Thank you in advance for any help or advice.

First, AlmaLinux 8 is already at “8.10” (and will remain on that to 2029).
The “8.8” became unsupported when files for “8.9” were released a year ago.
A simple dnf up should update system to 8.10 content.
Regular dnf up is a good thing to do.


The actual question is about Apache configuration. The only AlmaLinux-specific part of it is where the config files are.

All the “hosts” can be in one config file. I have somewhere:

$ cat /etc/httpd/conf.d/00-hosts.conf
#
# Ansible managed
#
<VirtualHost *:80>
  # something with HTTP
</VirtualHost>

<VirtualHost *:443>
  # something with HTTPS
</VirtualHost>

Listen 8443 https
<VirtualHost *:8443>
  # something else with HTTPS
</VirtualHost>

Yes, the three sections could be in different files.

There is no need for symlinks.


Sounds like you “load module” in more than one file.
I thought that modules are not loaded elsewhere. Once.

That is not the error though.


Lets say that you have two virtual hosts:

<VirtualHost www.here.com:443>
  # config for here
</VirtualHost>

<VirtualHost www.there.org:443>
  # config for there
</VirtualHost>

I’m a user, outside. I have browser. I write URL.
Either https://www.here.com/ or https://www.there.org/
My machine has to resolve these hostnames into IP address(es).
Public DNS should do that. I should get (same) answer with both:

$ dig www.here.com
$ dig www.there.org

If I would now try to dig the names of your four websites, would I get that IP address?
Do you?

Thank you jlehtone for such a comprehensive reply, this was very helpful and our domains are finally now working. Plus we have upgraded to AlmaLinus 8.10.

The dig command was great advice, and knowing rewite_module and symlinks were not an issue, we were able to zone in on other possible causes. We also used browser G__G__ More tools “Developer tools” to diagnose further the urls/domains/paths etc.

The problem was that we were using a new IP Address set-up on a new Apache 2.4 Server (for testing multiple VirtualHost websites in AlmaLinux, MySQL/PHP7), but we were using the wrong url-paths, eg: http://new.ip.address/domain.com - and this was returning a 404 Not Found error page.

My mistake was thinking the IP Address was somehow hard-coded into the Apache server, but of course it is the file domain.com.conf “ServerName / ServerAlias” matching only the “domain names” specified, NOT the IP address.

After we updated each of the domain names DNS settings (at the domain registrar):
A Records - HOST NAME / POINTS TO - New.IP.Address …the VirtualHost domains (eg. domain.com / www.domain.com) all worked (after a few hours for propagation).

For info, VirtualHost configuration files set-up in: /etc/httpd/conf.d/domain.com.conf:

<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/domain.com/public_html
<Directory /var/www/domain.com/public_html>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

And in the main Apache configuration file:
/etc/httpd/conf/httpd.conf …be sure this line is present:
IncludeOptional conf.d/*.conf

Hope this might help other people trying to resolve the same or similar issues.

Many thanks again jlehtone, this has been a major step forward.