Apache - virtual hosting - multiple (sub)domains
As a Web host, some key issues you will need to deal with when setting up a Web server include serving multiple domains on a single server, authorization, and authentication. In this second article on configuring Apache, Michael Swanson explains how to perform these tasks.
In the previous article in this series, we described how to set up a basic Apache Web server for simple, static HTML page hosting, and also explained how to create the virtual directory structure that Apache uses to serve files out on the Web. This article will address some of the more complex issues involved with configuring an Apache Web server. Specifically, we will address how to use virtual hosts to serve multiple domains on a single physical server, how to add modular functionality to handle specific types of files (server side pre-processing of files for things like PHP and Python), and how to use authentication and authorization schemes to control access to different parts of your website.
…
This creates a virtual host that listens to 123.234.111.222 on port 80 and serves the folder /www/myserver/ as the root of the myserver.mydomain.com domain. You can easily define multiple different blocks of these configurations to handle many domains. To use name based hosting, you will need to invoke the “NameVirtualHost? directive on the IP address for which you will be using Name-based Virtual Hosts. This is done with the following code:
Listen 123.234.111.222:80
…
NameVirtualHost 123.234.111.222
ServerName myserver1.mydomain.com
DocumentRoot /www/myserver1
ServerName myserver2.mydomain.com
DocumentRoot /www/myserver2
The above configuration will define two different hosts to be served on the 123.234.111.222 IP address. The “ServerName? directive in each “VirtualHost? block determines what files will be served based on the “Name? HTTP headers sent by the browser. This capability is very useful for small home-based Web serving environments where obtaining multiple actual WAN IP addresses would be difficult or impossible.
…
Apache - virtual hosting - multiple (sub)domains - nastavak…