/etc/apache2/
-------------------
I have added the following to my httpd.conf file:
NameVirtualHost *:80
ServerName marei.homelinux.com
ServerAlias marei.homelinux.com
DocumentRoot /srv/www/htdocs/
ServerName medicine.homelinux.com
DocumentRoot /srv/www/htdocs/phpBB3/
---------------------
then type to restart apache2:
rcapache2 restart or
/etc/init.d/apache2 restart
####################################
Using Name-based Virtual Hosts
Related Modules Related Directives
* DocumentRoot
* NameVirtualHost
* ServerAlias
* ServerName
* ServerPath
*
To use name-based virtual hosting, you must designate the IP address (and possibly port) on the server that will be accepting requests for the hosts. This is configured using the NameVirtualHost directive. In the normal case where any and all IP addresses on the server should be used, you can use * as the argument to NameVirtualHost. If you're planning to use multiple ports (e.g. running SSL) you should add a Port to the argument, such as *:80. Note that mentioning an IP address in a NameVirtualHost directive does not automatically make the server listen to that IP address. See Setting which addresses and ports Apache uses for more details. In addition, any IP address specified here must be associated with a network interface on the server.
The next step is to create a
Main host goes away
If you are adding virtual hosts to an existing web server, you must also create a
For example, suppose that you are serving the domain www.domain.tld and you wish to add the virtual host www.otherdomain.tld, which points at the same IP address. Then you simply add the following to httpd.conf:
NameVirtualHost *:80
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
You can alternatively specify an explicit IP address in place of the * in both the NameVirtualHost and
Many servers want to be accessible by more than one name. This is possible with the ServerAlias directive, placed inside the
ServerAlias domain.tld *.domain.tld
then requests for all hosts in the domain.tld domain will be served by the www.domain.tld virtual host. The wildcard characters * and ? can be used to match names. Of course, you can't just make up names and place them in ServerName or ServerAlias. You must first have your DNS server properly configured to map those names to an IP address associated with your server.
Finally, you can fine-tune the configuration of the virtual hosts by placing other directives inside the
Now when a request arrives, the server will first check if it is using an IP address that matches the NameVirtualHost. If it is, then it will look at each
As a consequence, the first listed virtual host is the default virtual host. The DocumentRoot from the main server will never be used when an IP address matches the NameVirtualHost directive. If you would like to have a special configuration for requests that do not match any particular virtual host, simply put that configuration in a
top
http://httpd.apache.org/docs/2.0/vhosts/name-based.html
http://httpd.apache.org/docs/2.0/vhosts/examples.html
--------------------------------
Keine Kommentare:
Kommentar veröffentlichen