[
351
]
Of course, there's more to Apache than simply installing it and having it present a
sample web page. While you could certainly replace the content in the sample web
page with your own and be all set when it comes to hosting content to your users,
there's much more to understand. For instance, there are several configuration files
in the
/etc/apache2
directory that govern how sites are hosted, as well as which
directories Apache will look in to find web pages to host. Apache also features
plugins, which we will go over as well.
The directory that Apache serves web pages from is known as the
document root
,
with
/var/www/html
being the default. Inside that directory, you'll see an
index.html
file, which is actually the default page you see when you visit an unmodified Apache
server. Essentially, this is a test page that is designed to show you that the server is
working, as well as some tidbits of information regarding the default configuration.
You're not limited to hosting just one website on a server, though. Apache supports
the concept of a
virtual host
, which allows you to serve multiple websites from a
single
server. Each virtual host consists of an individual configuration file, which
differentiates itself based on either name or IP address. For example, you could
have an Apache server with a single IP address that hosts two different websites,
such as
acmeconsulting.com
and
acmesales.com
. These are hypothetical websites,
but you get the idea. To set this up, you would create separate configuration
files for
acmeconsulting.com
and
acmesales.com
and store them in your Apache
configuration directory. Each configuration file would include a
stanza, where you would place an identifier such as a name or IP address that
differentiates one from the other. When a request comes in, Apache will serve either
acmeconsulting.com
or
acmesales.com
to the user's browser, depending on which
criteria matched when the request came in. The configuration files for each site
typically end with the
.conf
filename extension, and are stored in the
/etc/apache2/
sites-available
directory. We'll go over all of this in more detail shortly.
The basic workflow for setting up a new site (virtual host) will typically be similar to
the following:
•
The web developer creates the website and related files
•
These files are uploaded to Ubuntu Server, typically in a sub-directory of
/var/www
or another directory the administrator has chosen
•
The server administrator creates a configuration file for the site, and copies it
into the
/etc/apache2/sites-available
directory
• The administrator enables the site and reloads Apache
Serving Web Content
Do'stlaringiz bilan baham: |