Apache vhost directory never used
I’m setting a new server on Debian 9, but this time I’m struggling with the vhosts.
Basically, the vhosts never reach their DocumentRoot, but fallback on the default DocumentRoot (/var/www/html
). As this is usually a simple matter of finding the right configuration, this time I don’t get it to work.
I reduced the conf files to the strict minimum to work on the problem. Let’s take 2 vhosts conf examples:
<VirtualHost 127.0.0.1:80>
ServerName www.site1.com
ServerAlias www.site1.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site1
</VirtualHost>
<VirtualHost 127.0.0.1:80>
ServerName www.site2.com
ServerAlias www.site2.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site2
</VirtualHost>
In this case, going either on www.site1.com
or www.site2.com
will fall to the default page on /var/www/html
.
If I’m changing one of the 120.0.0.1:80
to *:80
, it is immediately set as the working vhost. But if I set both on *:80
, it will fall on the first in the list.
Meaning if I have this:
<VirtualHost 127.0.0.1:80>
ServerName www.site1.com
ServerAlias www.site1.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site1
</VirtualHost>
<VirtualHost *:80>
ServerName www.site2.com
ServerAlias www.site2.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site2
</VirtualHost>
www.site1.com
and www.site2.com
will lead to /var/www/site2
. Same the other way.
But if I do this :
<VirtualHost *:80>
ServerName www.site1.com
ServerAlias www.site1.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site1
</VirtualHost>
<VirtualHost *:80>
ServerName www.site2.com
ServerAlias www.site2.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site2
</VirtualHost>
Then www.site1.com
and www.site2.com
will fall on www.site1.com
.
I triple checked my apache.conf
, ports.conf
. They’re both on the default settings after a fresh install.
All the usual answers on "solved" similar posts have been tried and checked:apachectl -t
returns a Syntax OK
.
All conf files end with .conf
.
The chmod have been set to various tries, including 755, 775 and 777.
The matching user is set on the directories too.
I tried to sudo everything, restarting, reloading, etc.
I did reboot the server.
I’ve set the log on debug, but I can’f find everything wrong in it (though I’m not sure what to look for).
Just in case, here’s my /etc/hosts
:
127.0.0.1 localhost
127.0.1.1 sd-*****.dedibox.fr sd-****
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
and hostname:
sd-*****
I really don’t know what’s going on now. Thanks for any hint.
debian apache2 virtualhost
add a comment |
I’m setting a new server on Debian 9, but this time I’m struggling with the vhosts.
Basically, the vhosts never reach their DocumentRoot, but fallback on the default DocumentRoot (/var/www/html
). As this is usually a simple matter of finding the right configuration, this time I don’t get it to work.
I reduced the conf files to the strict minimum to work on the problem. Let’s take 2 vhosts conf examples:
<VirtualHost 127.0.0.1:80>
ServerName www.site1.com
ServerAlias www.site1.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site1
</VirtualHost>
<VirtualHost 127.0.0.1:80>
ServerName www.site2.com
ServerAlias www.site2.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site2
</VirtualHost>
In this case, going either on www.site1.com
or www.site2.com
will fall to the default page on /var/www/html
.
If I’m changing one of the 120.0.0.1:80
to *:80
, it is immediately set as the working vhost. But if I set both on *:80
, it will fall on the first in the list.
Meaning if I have this:
<VirtualHost 127.0.0.1:80>
ServerName www.site1.com
ServerAlias www.site1.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site1
</VirtualHost>
<VirtualHost *:80>
ServerName www.site2.com
ServerAlias www.site2.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site2
</VirtualHost>
www.site1.com
and www.site2.com
will lead to /var/www/site2
. Same the other way.
But if I do this :
<VirtualHost *:80>
ServerName www.site1.com
ServerAlias www.site1.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site1
</VirtualHost>
<VirtualHost *:80>
ServerName www.site2.com
ServerAlias www.site2.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site2
</VirtualHost>
Then www.site1.com
and www.site2.com
will fall on www.site1.com
.
I triple checked my apache.conf
, ports.conf
. They’re both on the default settings after a fresh install.
All the usual answers on "solved" similar posts have been tried and checked:apachectl -t
returns a Syntax OK
.
All conf files end with .conf
.
The chmod have been set to various tries, including 755, 775 and 777.
The matching user is set on the directories too.
I tried to sudo everything, restarting, reloading, etc.
I did reboot the server.
I’ve set the log on debug, but I can’f find everything wrong in it (though I’m not sure what to look for).
Just in case, here’s my /etc/hosts
:
127.0.0.1 localhost
127.0.1.1 sd-*****.dedibox.fr sd-****
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
and hostname:
sd-*****
I really don’t know what’s going on now. Thanks for any hint.
debian apache2 virtualhost
add a comment |
I’m setting a new server on Debian 9, but this time I’m struggling with the vhosts.
Basically, the vhosts never reach their DocumentRoot, but fallback on the default DocumentRoot (/var/www/html
). As this is usually a simple matter of finding the right configuration, this time I don’t get it to work.
I reduced the conf files to the strict minimum to work on the problem. Let’s take 2 vhosts conf examples:
<VirtualHost 127.0.0.1:80>
ServerName www.site1.com
ServerAlias www.site1.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site1
</VirtualHost>
<VirtualHost 127.0.0.1:80>
ServerName www.site2.com
ServerAlias www.site2.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site2
</VirtualHost>
In this case, going either on www.site1.com
or www.site2.com
will fall to the default page on /var/www/html
.
If I’m changing one of the 120.0.0.1:80
to *:80
, it is immediately set as the working vhost. But if I set both on *:80
, it will fall on the first in the list.
Meaning if I have this:
<VirtualHost 127.0.0.1:80>
ServerName www.site1.com
ServerAlias www.site1.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site1
</VirtualHost>
<VirtualHost *:80>
ServerName www.site2.com
ServerAlias www.site2.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site2
</VirtualHost>
www.site1.com
and www.site2.com
will lead to /var/www/site2
. Same the other way.
But if I do this :
<VirtualHost *:80>
ServerName www.site1.com
ServerAlias www.site1.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site1
</VirtualHost>
<VirtualHost *:80>
ServerName www.site2.com
ServerAlias www.site2.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site2
</VirtualHost>
Then www.site1.com
and www.site2.com
will fall on www.site1.com
.
I triple checked my apache.conf
, ports.conf
. They’re both on the default settings after a fresh install.
All the usual answers on "solved" similar posts have been tried and checked:apachectl -t
returns a Syntax OK
.
All conf files end with .conf
.
The chmod have been set to various tries, including 755, 775 and 777.
The matching user is set on the directories too.
I tried to sudo everything, restarting, reloading, etc.
I did reboot the server.
I’ve set the log on debug, but I can’f find everything wrong in it (though I’m not sure what to look for).
Just in case, here’s my /etc/hosts
:
127.0.0.1 localhost
127.0.1.1 sd-*****.dedibox.fr sd-****
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
and hostname:
sd-*****
I really don’t know what’s going on now. Thanks for any hint.
debian apache2 virtualhost
I’m setting a new server on Debian 9, but this time I’m struggling with the vhosts.
Basically, the vhosts never reach their DocumentRoot, but fallback on the default DocumentRoot (/var/www/html
). As this is usually a simple matter of finding the right configuration, this time I don’t get it to work.
I reduced the conf files to the strict minimum to work on the problem. Let’s take 2 vhosts conf examples:
<VirtualHost 127.0.0.1:80>
ServerName www.site1.com
ServerAlias www.site1.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site1
</VirtualHost>
<VirtualHost 127.0.0.1:80>
ServerName www.site2.com
ServerAlias www.site2.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site2
</VirtualHost>
In this case, going either on www.site1.com
or www.site2.com
will fall to the default page on /var/www/html
.
If I’m changing one of the 120.0.0.1:80
to *:80
, it is immediately set as the working vhost. But if I set both on *:80
, it will fall on the first in the list.
Meaning if I have this:
<VirtualHost 127.0.0.1:80>
ServerName www.site1.com
ServerAlias www.site1.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site1
</VirtualHost>
<VirtualHost *:80>
ServerName www.site2.com
ServerAlias www.site2.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site2
</VirtualHost>
www.site1.com
and www.site2.com
will lead to /var/www/site2
. Same the other way.
But if I do this :
<VirtualHost *:80>
ServerName www.site1.com
ServerAlias www.site1.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site1
</VirtualHost>
<VirtualHost *:80>
ServerName www.site2.com
ServerAlias www.site2.com
ServerAdmin contact@test.com
DocumentRoot /var/www/site2
</VirtualHost>
Then www.site1.com
and www.site2.com
will fall on www.site1.com
.
I triple checked my apache.conf
, ports.conf
. They’re both on the default settings after a fresh install.
All the usual answers on "solved" similar posts have been tried and checked:apachectl -t
returns a Syntax OK
.
All conf files end with .conf
.
The chmod have been set to various tries, including 755, 775 and 777.
The matching user is set on the directories too.
I tried to sudo everything, restarting, reloading, etc.
I did reboot the server.
I’ve set the log on debug, but I can’f find everything wrong in it (though I’m not sure what to look for).
Just in case, here’s my /etc/hosts
:
127.0.0.1 localhost
127.0.1.1 sd-*****.dedibox.fr sd-****
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
and hostname:
sd-*****
I really don’t know what’s going on now. Thanks for any hint.
debian apache2 virtualhost
debian apache2 virtualhost
asked Nov 14 '18 at 9:42
EmmanuelBeziatEmmanuelBeziat
227114
227114
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Okay, for some odd reasons I managed to get it to work with the second scheme, putting every vhost as *:80
.
Although it works, I have no clue about why my usual settings didn't work this time, nor about what I did to get it to work…
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53297104%2fapache-vhost-directory-never-used%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Okay, for some odd reasons I managed to get it to work with the second scheme, putting every vhost as *:80
.
Although it works, I have no clue about why my usual settings didn't work this time, nor about what I did to get it to work…
add a comment |
Okay, for some odd reasons I managed to get it to work with the second scheme, putting every vhost as *:80
.
Although it works, I have no clue about why my usual settings didn't work this time, nor about what I did to get it to work…
add a comment |
Okay, for some odd reasons I managed to get it to work with the second scheme, putting every vhost as *:80
.
Although it works, I have no clue about why my usual settings didn't work this time, nor about what I did to get it to work…
Okay, for some odd reasons I managed to get it to work with the second scheme, putting every vhost as *:80
.
Although it works, I have no clue about why my usual settings didn't work this time, nor about what I did to get it to work…
answered Nov 22 '18 at 23:23
EmmanuelBeziatEmmanuelBeziat
227114
227114
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53297104%2fapache-vhost-directory-never-used%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown