Score:1

Issue with Apache 2.4 and VirtualHosts

us flag

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 [email protected]
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 [email protected]
    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 [email protected]
    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.

us flag
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.
us flag
Rob
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
Jorge Hernandez avatar
us flag
thanks Rob this worked
Score:0
us flag

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

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.