1

Can somebody tell me what I'm doing wrong here, I have 1 server running Apache 2.4 with 3 VirtualHosts in it, setup this way:

<VirtualHost helpedsk.example.com:80>
ServerAdmin nobody@example.com
DocumentRoot "${SRVROOT}/htdocs/hesk"
ServerName helpdesk.example.com
ErrorLog "logs/error.log"
CustomLog "logs/access.log" common
    <Directory "${SRVROOT}/htdocs/hesk">
        Require all granted
        Options Indexes FollowSymLinks ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost wiki.example.com:80>
    ServerAdmin nobody@example.com
    DocumentRoot "${SRVROOT}/htdocs/dokuwiki"
    ServerName wiki.example.com
    ErrorLog "logs/error.log"
    CustomLog "logs/access.log" common
    <Directory "${SRVROOT}/htdocs/dokuwiki">
        Require all granted
        Options Indexes FollowSymLinks ExecCGI
        AllowOverride All
        Require all granted
    </Directory>

</VirtualHost>

<VirtualHost docs.example.com:80>
    ServerAdmin nobody@example.com
    DocumentRoot "${SRVROOT}/htdocs/drupal"
    ServerName docs.example.com
    ErrorLog "logs/error.log"
    CustomLog "logs/access.log" common
    <Directory "${SRVROOT}/htdocs/drupal">
        Require all granted
        Options Indexes FollowSymLinks ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

But for some reason only the last one works, the first one shows me the the document root of the server (without hesk) and the second one goes into an unlimited redirection to itself and I can't figure out why, the second one probably has to do because I set it up pointing to the server ip/dokuwiki that I can change later, but why is the first one not going to hesk?

All these sites work fine when accessed using serverip/site but when trying to be accessed by name, only the last one works.

  • Can you post the output of `httpd -S` (or `apache2ctl -S` on Debian/Ubuntu) - this will show a summary of your configuration which will be useful. – JamesHannah Apr 28 '22 at 14:53
  • In general: rather than `VirtualHost helpedsk.example.com:80>` use `VirtualHost *:80>` - did you restart apache after making the latest changes in the config? - for an approach to debugging https://serverfault.com/questions/1092950/my-browser-will-not-display-http-sub-example-com might be useful – Rob Apr 28 '22 at 14:55
  • thanks Rob this worked – Jorge Hernandez Apr 28 '22 at 16:20

1 Answers1

0

Never mind, I changed all the VirtualHost lines for *:80 leaving the ServerName in them with the site url and it's working now.