Apache virtual host does not work properly

Posted by Jori on Pro Webmasters See other posts from Pro Webmasters or by Jori
Published on 2013-06-30T13:37:37Z Indexed on 2013/06/30 16:28 UTC
Read the original article Hit count: 476

Filed under:
|

I have read a lot of information all over the Internet regarding this subject, and can not figure out what I'am doing wrong. I'm trying to host two websites under different names locally under Windows 7 with Apaches Virtual Hosting functionality. This is what I have done already:

In the httpd.conf file I uncommented the following line, so that the virtual host configuration file will be included in the main configuration sequence.

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

This is how I edited my httpd-vhosts.conf:

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
#<VirtualHost *:80>
#    ServerAdmin [email protected]
#    DocumentRoot "C:/apache/docs/dummy-host.localhost"
#    ServerName dummy-host.localhost
#    ServerAlias www.dummy-host.localhost
#    ErrorLog "logs/dummy-host.localhost-error.log"
#    CustomLog "logs/dummy-host.localhost-access.log" common
#</VirtualHost>
#
#<VirtualHost *:80>
#    ServerAdmin [email protected]
#    DocumentRoot "C:/apache/docs/dummy-host2.localhost"
#    ServerName dummy-host2.localhost
#    ErrorLog "logs/dummy-host2.localhost-error.log"
#    CustomLog "logs/dummy-host2.localhost-access.log" common
#</VirtualHost>


<VirtualHost *:80>

 ServerName arterieur
 DocumentRoot "J:/webcontent/www20"

 <Directory "J:/webcontent/www20">
  Order allow,deny
  Allow from all
 </Directory>

</VirtualHost>

As you can see I commented the Virtual Host examples out and added my own one (I did one for this example). Also am I sure that J:\webcontent\www20 exists.

At last I edited the Windows host file located in: C:\Windows\System32\drivers\etc\hosts, now it looks this:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

    127.0.0.1   arterieur

Then I restarted Apache with the Apache Service Monitor, and it gave me the following fatal error: The requested operation has failed!, I tried to look at the apache/logs/error.log file but I did not log anything, I guess it only logs the errors after startup.

Does anyone knows what I'am doing wrong?

© Pro Webmasters or respective owner

Related posts about apache

Related posts about virtualhost