Editing /etc/hosts causes Apache server block to be missed
up vote
0
down vote
favorite
In order to fix some email (SPF) issues, I changed my Ubuntu VPS hostname to its FQDN in /etc/hosts
and /etc/hostname
. However, now, when I hit the URL in a browser I get a 404 from Apache instead of triggering the block in /etc/apache2/sites-available/example.com
which would redirect to the www
version of the site. Typing www.example.com
still works.
My hosts file now looks like this:
127.0.0.1 localhost
256.256.256.256 example.com # I am using a real IP and FQDN, obviously
I don't know enough about it to know why Apache is serving up a 404. It says The requested URL / cannot be found on this server
and nothing else. Why did editing my hosts
file cause this?
apache2 hosts
 |Â
show 1 more comment
up vote
0
down vote
favorite
In order to fix some email (SPF) issues, I changed my Ubuntu VPS hostname to its FQDN in /etc/hosts
and /etc/hostname
. However, now, when I hit the URL in a browser I get a 404 from Apache instead of triggering the block in /etc/apache2/sites-available/example.com
which would redirect to the www
version of the site. Typing www.example.com
still works.
My hosts file now looks like this:
127.0.0.1 localhost
256.256.256.256 example.com # I am using a real IP and FQDN, obviously
I don't know enough about it to know why Apache is serving up a 404. It says The requested URL / cannot be found on this server
and nothing else. Why did editing my hosts
file cause this?
apache2 hosts
I deleted the entry in/etc/hosts
with the IP and domain and it's still happening - could it actually be/etc/hostname
that is causing the issue?
â armadadrive
Feb 5 at 21:33
Figured it out -000-default.conf
is actually enabled and needs to be updated, whereas I never paid it any attention before since everything "just worked".
â armadadrive
Feb 5 at 21:50
Don't put the FQDN in your/etc/hosts
or/etc/hostname
- this should just be the locally known hostname for your machine, otherwise a few things will work weirdly. Also, what is in there is not related to your Apache setup or how people on the internet find your machine.
â thomasrutter
Feb 5 at 22:45
If I didn't do that then mail sent from that machine was failing SPF because the machine was sending asmymachinename.local
in mail headers I examined.
â armadadrive
Feb 5 at 22:56
You need to configure the mail hostname in your MTA, egmyhostname
in postfix. Set this to a FQDN, or set it to a blank string and setmydomain
and it'll automatically determine the FQDN. No need to change/etc/hostname
or/etc/hosts
to something non-standard just to try and influence one service because what's in those files can effect other things on the system.
â thomasrutter
Feb 6 at 1:52
 |Â
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
In order to fix some email (SPF) issues, I changed my Ubuntu VPS hostname to its FQDN in /etc/hosts
and /etc/hostname
. However, now, when I hit the URL in a browser I get a 404 from Apache instead of triggering the block in /etc/apache2/sites-available/example.com
which would redirect to the www
version of the site. Typing www.example.com
still works.
My hosts file now looks like this:
127.0.0.1 localhost
256.256.256.256 example.com # I am using a real IP and FQDN, obviously
I don't know enough about it to know why Apache is serving up a 404. It says The requested URL / cannot be found on this server
and nothing else. Why did editing my hosts
file cause this?
apache2 hosts
In order to fix some email (SPF) issues, I changed my Ubuntu VPS hostname to its FQDN in /etc/hosts
and /etc/hostname
. However, now, when I hit the URL in a browser I get a 404 from Apache instead of triggering the block in /etc/apache2/sites-available/example.com
which would redirect to the www
version of the site. Typing www.example.com
still works.
My hosts file now looks like this:
127.0.0.1 localhost
256.256.256.256 example.com # I am using a real IP and FQDN, obviously
I don't know enough about it to know why Apache is serving up a 404. It says The requested URL / cannot be found on this server
and nothing else. Why did editing my hosts
file cause this?
apache2 hosts
apache2 hosts
asked Feb 5 at 21:22
armadadrive
61857
61857
I deleted the entry in/etc/hosts
with the IP and domain and it's still happening - could it actually be/etc/hostname
that is causing the issue?
â armadadrive
Feb 5 at 21:33
Figured it out -000-default.conf
is actually enabled and needs to be updated, whereas I never paid it any attention before since everything "just worked".
â armadadrive
Feb 5 at 21:50
Don't put the FQDN in your/etc/hosts
or/etc/hostname
- this should just be the locally known hostname for your machine, otherwise a few things will work weirdly. Also, what is in there is not related to your Apache setup or how people on the internet find your machine.
â thomasrutter
Feb 5 at 22:45
If I didn't do that then mail sent from that machine was failing SPF because the machine was sending asmymachinename.local
in mail headers I examined.
â armadadrive
Feb 5 at 22:56
You need to configure the mail hostname in your MTA, egmyhostname
in postfix. Set this to a FQDN, or set it to a blank string and setmydomain
and it'll automatically determine the FQDN. No need to change/etc/hostname
or/etc/hosts
to something non-standard just to try and influence one service because what's in those files can effect other things on the system.
â thomasrutter
Feb 6 at 1:52
 |Â
show 1 more comment
I deleted the entry in/etc/hosts
with the IP and domain and it's still happening - could it actually be/etc/hostname
that is causing the issue?
â armadadrive
Feb 5 at 21:33
Figured it out -000-default.conf
is actually enabled and needs to be updated, whereas I never paid it any attention before since everything "just worked".
â armadadrive
Feb 5 at 21:50
Don't put the FQDN in your/etc/hosts
or/etc/hostname
- this should just be the locally known hostname for your machine, otherwise a few things will work weirdly. Also, what is in there is not related to your Apache setup or how people on the internet find your machine.
â thomasrutter
Feb 5 at 22:45
If I didn't do that then mail sent from that machine was failing SPF because the machine was sending asmymachinename.local
in mail headers I examined.
â armadadrive
Feb 5 at 22:56
You need to configure the mail hostname in your MTA, egmyhostname
in postfix. Set this to a FQDN, or set it to a blank string and setmydomain
and it'll automatically determine the FQDN. No need to change/etc/hostname
or/etc/hosts
to something non-standard just to try and influence one service because what's in those files can effect other things on the system.
â thomasrutter
Feb 6 at 1:52
I deleted the entry in
/etc/hosts
with the IP and domain and it's still happening - could it actually be /etc/hostname
that is causing the issue?â armadadrive
Feb 5 at 21:33
I deleted the entry in
/etc/hosts
with the IP and domain and it's still happening - could it actually be /etc/hostname
that is causing the issue?â armadadrive
Feb 5 at 21:33
Figured it out -
000-default.conf
is actually enabled and needs to be updated, whereas I never paid it any attention before since everything "just worked".â armadadrive
Feb 5 at 21:50
Figured it out -
000-default.conf
is actually enabled and needs to be updated, whereas I never paid it any attention before since everything "just worked".â armadadrive
Feb 5 at 21:50
Don't put the FQDN in your
/etc/hosts
or /etc/hostname
- this should just be the locally known hostname for your machine, otherwise a few things will work weirdly. Also, what is in there is not related to your Apache setup or how people on the internet find your machine.â thomasrutter
Feb 5 at 22:45
Don't put the FQDN in your
/etc/hosts
or /etc/hostname
- this should just be the locally known hostname for your machine, otherwise a few things will work weirdly. Also, what is in there is not related to your Apache setup or how people on the internet find your machine.â thomasrutter
Feb 5 at 22:45
If I didn't do that then mail sent from that machine was failing SPF because the machine was sending as
mymachinename.local
in mail headers I examined.â armadadrive
Feb 5 at 22:56
If I didn't do that then mail sent from that machine was failing SPF because the machine was sending as
mymachinename.local
in mail headers I examined.â armadadrive
Feb 5 at 22:56
You need to configure the mail hostname in your MTA, eg
myhostname
in postfix. Set this to a FQDN, or set it to a blank string and set mydomain
and it'll automatically determine the FQDN. No need to change /etc/hostname
or /etc/hosts
to something non-standard just to try and influence one service because what's in those files can effect other things on the system.â thomasrutter
Feb 6 at 1:52
You need to configure the mail hostname in your MTA, eg
myhostname
in postfix. Set this to a FQDN, or set it to a blank string and set mydomain
and it'll automatically determine the FQDN. No need to change /etc/hostname
or /etc/hosts
to something non-standard just to try and influence one service because what's in those files can effect other things on the system.â thomasrutter
Feb 6 at 1:52
 |Â
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
0
down vote
The issue is actually in the default Apache configuration file (/etc/apache2/sites-available/000-default.conf
).
Uncomment the line:
#ServerName example.com
and add your server's FQDN (fully qualified domain name).
Finally, run sudo service apache2 reload
to have Apache pickup on the config file change.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The issue is actually in the default Apache configuration file (/etc/apache2/sites-available/000-default.conf
).
Uncomment the line:
#ServerName example.com
and add your server's FQDN (fully qualified domain name).
Finally, run sudo service apache2 reload
to have Apache pickup on the config file change.
add a comment |Â
up vote
0
down vote
The issue is actually in the default Apache configuration file (/etc/apache2/sites-available/000-default.conf
).
Uncomment the line:
#ServerName example.com
and add your server's FQDN (fully qualified domain name).
Finally, run sudo service apache2 reload
to have Apache pickup on the config file change.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
The issue is actually in the default Apache configuration file (/etc/apache2/sites-available/000-default.conf
).
Uncomment the line:
#ServerName example.com
and add your server's FQDN (fully qualified domain name).
Finally, run sudo service apache2 reload
to have Apache pickup on the config file change.
The issue is actually in the default Apache configuration file (/etc/apache2/sites-available/000-default.conf
).
Uncomment the line:
#ServerName example.com
and add your server's FQDN (fully qualified domain name).
Finally, run sudo service apache2 reload
to have Apache pickup on the config file change.
answered Feb 5 at 21:49
armadadrive
61857
61857
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1003369%2fediting-etc-hosts-causes-apache-server-block-to-be-missed%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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
I deleted the entry in
/etc/hosts
with the IP and domain and it's still happening - could it actually be/etc/hostname
that is causing the issue?â armadadrive
Feb 5 at 21:33
Figured it out -
000-default.conf
is actually enabled and needs to be updated, whereas I never paid it any attention before since everything "just worked".â armadadrive
Feb 5 at 21:50
Don't put the FQDN in your
/etc/hosts
or/etc/hostname
- this should just be the locally known hostname for your machine, otherwise a few things will work weirdly. Also, what is in there is not related to your Apache setup or how people on the internet find your machine.â thomasrutter
Feb 5 at 22:45
If I didn't do that then mail sent from that machine was failing SPF because the machine was sending as
mymachinename.local
in mail headers I examined.â armadadrive
Feb 5 at 22:56
You need to configure the mail hostname in your MTA, eg
myhostname
in postfix. Set this to a FQDN, or set it to a blank string and setmydomain
and it'll automatically determine the FQDN. No need to change/etc/hostname
or/etc/hosts
to something non-standard just to try and influence one service because what's in those files can effect other things on the system.â thomasrutter
Feb 6 at 1:52