Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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 webmaster@dummy-host.localhost
#    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 webmaster@dummy-host2.localhost
#    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?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Test your config with this commandline:

httpd -t

This will tell any error in config files.

Maybe you receive this error: ServerName takes one argument, the Host name and port of the server.

Try to configure it like this:

ServerName arterieur.localhost

and in the hosts file add this:

127.0.0.1 arterieur.localhost

This way is configured the way ServerName has to be configured.

If this does not work, use ServerAlias instead of ServerName.

And if this does not work, check that your Apache service is not disabled: Open services.msc and check the Apache service, make sure it's not disabled. It should be set to Manual or Automatic start-up, depending on your environment.

EDIT: Now talking with questioner we reached an answer:

The exact problem was that running httpd by service, the process don't had permissions to write to the J: drive, but when running it in commandline everything worked fine.

As @Jori said, services.exe runs under SYSTEM user, so seems that running httpd by service inherits services.exe rights, so he changed J: drive permissions for user SYSTEM and then worked fine.

share|improve this answer
    
I will try this tomorrow and report back then. I do not have an apache executable however, did you mean htppd? –  user29263 Jun 30 '13 at 18:49
    
Yes, sorry for the error, going to edit it. –  Jorge Fuentes González Jun 30 '13 at 19:03
    
I tested your solution and at first when running httpd -t it outputed: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName. Now it is just Syntax Ok. But I still get the same error message, what is your other solution? –  user29263 Jun 30 '13 at 19:08
1  
Haha, we are not supposed to chat like this here, but who cares: have a nice dinner, will report back (; . –  user29263 Jun 30 '13 at 20:08
1  
Yes, I think that would be a good idea. It is not something you would except at first. Again, thanks for all the help. –  user29263 Jul 1 '13 at 11:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.