Bog'liq Mastering Ubuntu Server Gain expertise in the art of deploying, configuring, managing, and troubleshooting Ubuntu Server by Jay LaCroix (z-lib.org)
[ 353 ] As you can see, this is how Ubuntu has configured Apache to look for enabled sites
in the
/etc/apache2/sites-enabled
directory. Any file stored there with the
.conf
file extension is read by Apache. If you wish, you could actually remove those lines
and Apache would then behave as it does on other platforms, and the
a2ensite
and
a2dissite
commands would no longer have any purpose. However, it's best to keep
the framework of Ubuntu's implementation intact, as separating the configuration
files makes logical sense and helps simplify the configuration. This chapter will go
along with the Ubuntu way of managing configuration.
An additional virtual host is not required if you're only hosting a single site. The
contents of
/var/www/html
are served by the default virtual host if you make no
changes to Apache's configuration. This is where the example site that ships with
Apache comes from. If you only need to host one site, you could remove the default
index.html
file stored in this directory and replace it with the files required by your
website. If you wish to test this for yourself, you can make a backup copy of the
default
index.html
file and create a new one with some standard HTML. You should
see the default page change to feature the content you just added to the file.
The
000-default.conf
file is special, in that it's basically the configuration file that
controls the default Apache sample website. If you look at the contents of the
/etc/
apache2/sites-available
and
/etc/apache2/sites-enabled
directories, you'll see
the
000-default.conf
configuration file stored in
sites-available
and
symlinked
in
sites-enabled
. This shows you that, by default, this site was included with Apache,
and its configuration file was enabled as soon as Apache was installed. For all
intents and purposes, the
000-default.conf
configuration file is all you need if you
only plan on hosting a single website on your server. The contents of this file are as
follows, but I've stripped the comments out of the file in order to save space on this
page:
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
As you can see, this default virtual host is telling Apache to listen on port
80
for
requests and to serve content from
/var/www/html
as soon as requests come in. The
declaration at the beginning is listening to everything (the asterisk
is a
wildcard ) on port
80
, so this is basically handling all web traffic that comes into
the server from port
80
. The
ServerAdmin
clause specifies the email address that is
displayed in any error messages shown if there is a problem with the site.