How configure apache (vhost) for Server-Hostname
First of all, sorry for my imperfect English.
But let me explain my problem with apache vhosts.
Example:
My servername is example.de (/etc/hostname). If I configure for this specific domain my vhost won´t work. It seems apache uses the default-vhost. But I need the default-vhost for pages that are not active on my server. So I can´t use it for the domain example.de
I need a solution for following problem:
- example.de - Should point to /var/www/example (This doesn´t work,
because /etc/hostanme) - example2.de - Should point to /var/www/example2
(This works) - domain-i-got-but-not-active.de Should point to
/var/www/default (This works, but also catches example.de)
I can´t change my hostname, because mails sent from my server will be detect as spam if the server name is not correctly set.
Here is an example of my vhost:
# For default-pages
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/default
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/default>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
# Doesn´t work, points to default (above code)
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.de
DocumentRoot /var/www/example
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/example>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
# All fine
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example2.de
DocumentRoot /var/www/example2
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/example2>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
server apache2 hostname
add a comment |
First of all, sorry for my imperfect English.
But let me explain my problem with apache vhosts.
Example:
My servername is example.de (/etc/hostname). If I configure for this specific domain my vhost won´t work. It seems apache uses the default-vhost. But I need the default-vhost for pages that are not active on my server. So I can´t use it for the domain example.de
I need a solution for following problem:
- example.de - Should point to /var/www/example (This doesn´t work,
because /etc/hostanme) - example2.de - Should point to /var/www/example2
(This works) - domain-i-got-but-not-active.de Should point to
/var/www/default (This works, but also catches example.de)
I can´t change my hostname, because mails sent from my server will be detect as spam if the server name is not correctly set.
Here is an example of my vhost:
# For default-pages
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/default
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/default>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
# Doesn´t work, points to default (above code)
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.de
DocumentRoot /var/www/example
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/example>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
# All fine
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example2.de
DocumentRoot /var/www/example2
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/example2>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
server apache2 hostname
That's why we have moderators. Und dein English is nicht "scheissig"! Nur "Imperfekt"
– Fabby
Nov 26 '14 at 0:40
add a comment |
First of all, sorry for my imperfect English.
But let me explain my problem with apache vhosts.
Example:
My servername is example.de (/etc/hostname). If I configure for this specific domain my vhost won´t work. It seems apache uses the default-vhost. But I need the default-vhost for pages that are not active on my server. So I can´t use it for the domain example.de
I need a solution for following problem:
- example.de - Should point to /var/www/example (This doesn´t work,
because /etc/hostanme) - example2.de - Should point to /var/www/example2
(This works) - domain-i-got-but-not-active.de Should point to
/var/www/default (This works, but also catches example.de)
I can´t change my hostname, because mails sent from my server will be detect as spam if the server name is not correctly set.
Here is an example of my vhost:
# For default-pages
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/default
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/default>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
# Doesn´t work, points to default (above code)
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.de
DocumentRoot /var/www/example
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/example>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
# All fine
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example2.de
DocumentRoot /var/www/example2
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/example2>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
server apache2 hostname
First of all, sorry for my imperfect English.
But let me explain my problem with apache vhosts.
Example:
My servername is example.de (/etc/hostname). If I configure for this specific domain my vhost won´t work. It seems apache uses the default-vhost. But I need the default-vhost for pages that are not active on my server. So I can´t use it for the domain example.de
I need a solution for following problem:
- example.de - Should point to /var/www/example (This doesn´t work,
because /etc/hostanme) - example2.de - Should point to /var/www/example2
(This works) - domain-i-got-but-not-active.de Should point to
/var/www/default (This works, but also catches example.de)
I can´t change my hostname, because mails sent from my server will be detect as spam if the server name is not correctly set.
Here is an example of my vhost:
# For default-pages
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/default
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/default>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
# Doesn´t work, points to default (above code)
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.de
DocumentRoot /var/www/example
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/example>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
# All fine
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example2.de
DocumentRoot /var/www/example2
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/example2>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
server apache2 hostname
server apache2 hostname
edited Nov 26 '14 at 0:37
Fabby
26.5k1360159
26.5k1360159
asked Nov 23 '14 at 21:55
TatzyXY
612
612
That's why we have moderators. Und dein English is nicht "scheissig"! Nur "Imperfekt"
– Fabby
Nov 26 '14 at 0:40
add a comment |
That's why we have moderators. Und dein English is nicht "scheissig"! Nur "Imperfekt"
– Fabby
Nov 26 '14 at 0:40
That's why we have moderators. Und dein English is nicht "scheissig"! Nur "Imperfekt"
– Fabby
Nov 26 '14 at 0:40
That's why we have moderators. Und dein English is nicht "scheissig"! Nur "Imperfekt"
– Fabby
Nov 26 '14 at 0:40
add a comment |
2 Answers
2
active
oldest
votes
According to Apache documentation:
If no ServerName is specified, then the server attempts to deduce the
hostname by performing a reverse lookup on the IP address.
Reverse lookup: Look up an IP address to find the domain name for the IP address.
I guess that this is why example.de
is served by your default VirtualHost
, so try to add ServerName domain-i-got-but-not-active.de
, and if this VirtualHost
is the first defined:
it has the highest priority and can be seen as the default or primary
server. That means that if a request is received that does not match
one of the specified ServerName directives, it will be served by this
first VirtualHost.
add a comment |
<VirtualHost *:80>
DocumentRoot /var/www/example
DirectoryIndex index.php
ServerName example.de
setEnv DOMAIN_NAME example.de
<Directory "/var/www/example">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
try this
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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%2faskubuntu.com%2fquestions%2f553019%2fhow-configure-apache-vhost-for-server-hostname%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
According to Apache documentation:
If no ServerName is specified, then the server attempts to deduce the
hostname by performing a reverse lookup on the IP address.
Reverse lookup: Look up an IP address to find the domain name for the IP address.
I guess that this is why example.de
is served by your default VirtualHost
, so try to add ServerName domain-i-got-but-not-active.de
, and if this VirtualHost
is the first defined:
it has the highest priority and can be seen as the default or primary
server. That means that if a request is received that does not match
one of the specified ServerName directives, it will be served by this
first VirtualHost.
add a comment |
According to Apache documentation:
If no ServerName is specified, then the server attempts to deduce the
hostname by performing a reverse lookup on the IP address.
Reverse lookup: Look up an IP address to find the domain name for the IP address.
I guess that this is why example.de
is served by your default VirtualHost
, so try to add ServerName domain-i-got-but-not-active.de
, and if this VirtualHost
is the first defined:
it has the highest priority and can be seen as the default or primary
server. That means that if a request is received that does not match
one of the specified ServerName directives, it will be served by this
first VirtualHost.
add a comment |
According to Apache documentation:
If no ServerName is specified, then the server attempts to deduce the
hostname by performing a reverse lookup on the IP address.
Reverse lookup: Look up an IP address to find the domain name for the IP address.
I guess that this is why example.de
is served by your default VirtualHost
, so try to add ServerName domain-i-got-but-not-active.de
, and if this VirtualHost
is the first defined:
it has the highest priority and can be seen as the default or primary
server. That means that if a request is received that does not match
one of the specified ServerName directives, it will be served by this
first VirtualHost.
According to Apache documentation:
If no ServerName is specified, then the server attempts to deduce the
hostname by performing a reverse lookup on the IP address.
Reverse lookup: Look up an IP address to find the domain name for the IP address.
I guess that this is why example.de
is served by your default VirtualHost
, so try to add ServerName domain-i-got-but-not-active.de
, and if this VirtualHost
is the first defined:
it has the highest priority and can be seen as the default or primary
server. That means that if a request is received that does not match
one of the specified ServerName directives, it will be served by this
first VirtualHost.
answered Nov 24 '14 at 0:31
Lety
4,94521730
4,94521730
add a comment |
add a comment |
<VirtualHost *:80>
DocumentRoot /var/www/example
DirectoryIndex index.php
ServerName example.de
setEnv DOMAIN_NAME example.de
<Directory "/var/www/example">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
try this
add a comment |
<VirtualHost *:80>
DocumentRoot /var/www/example
DirectoryIndex index.php
ServerName example.de
setEnv DOMAIN_NAME example.de
<Directory "/var/www/example">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
try this
add a comment |
<VirtualHost *:80>
DocumentRoot /var/www/example
DirectoryIndex index.php
ServerName example.de
setEnv DOMAIN_NAME example.de
<Directory "/var/www/example">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
try this
<VirtualHost *:80>
DocumentRoot /var/www/example
DirectoryIndex index.php
ServerName example.de
setEnv DOMAIN_NAME example.de
<Directory "/var/www/example">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
try this
answered Nov 16 '18 at 20:07
GHOST
269111
269111
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2faskubuntu.com%2fquestions%2f553019%2fhow-configure-apache-vhost-for-server-hostname%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
That's why we have moderators. Und dein English is nicht "scheissig"! Nur "Imperfekt"
– Fabby
Nov 26 '14 at 0:40