Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

VirtualHost on apache 2.2 (Win32)

A beginner's cry for help...



10:06 am on Dec 1, 2006 (gmt 0)

10+ Year Member

I'm running apache 2.2 on win32 and have this problem, virtual host does not work. Below is the httpd.conf file.

The server is running but shows only the index.html from the /htdocs/ dir, not the index.html from the virtual host.

At the virtual host folder I have made an index.php file and requests for this file shows in the error log as

/htdocs/index.php not found, so i seems like apache is not responding to the virtual host command.

When i type www.mydomain.com in IE I get the "It Works!" index.html from the server root, not the index.html

from www.mydomain.com, All IP numbers, DNS etc. works fine, i.e. ping www.mydomain.com gives the right IP

There are no linebreaks in the original httpd.conf

-------httpd.conf (without comments)Start------------

httpd.conf (without comments):

<IfModule mpm_winnt.c>
ThreadsPerChild 250
MaxRequestsPerChild 0

ServerRoot "C:/Program Files/Apache Software Foundation/Apache2.2"

PidFile logs/httpd.pid

Timeout 800

KeepAlive On

MaxKeepAliveRequests 100

KeepAliveTimeout 15

Listen 80

#LoadModule access_module modules/mod_access.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule asis_module modules/mod_asis.so
#LoadModule auth_module modules/mod_auth.so
LoadModule auth_basic_module modules/mod_auth_basic.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule authn_anon_module modules/mod_authn_anon.so
#LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authn_file_module modules/mod_authn_file.so
#LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
#LoadModule cern_meta_module modules/mod_cern_meta.so
LoadModule cgi_module modules/mod_cgi.so
#LoadModule dav_module modules/mod_dav.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule deflate_module modules/mod_deflate.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
#LoadModule expires_module modules/mod_expires.so
#LoadModule file_cache_module modules/mod_file_cache.so
#LoadModule headers_module modules/mod_headers.so
LoadModule imagemap_module modules/mod_imagemap.so
#LoadModule imap_module modules/mod_imap.so
LoadModule include_module modules/mod_include.so
#LoadModule info_module modules/mod_info.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
#LoadModule mime_magic_module modules/mod_mime_magic.so
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule status_module modules/mod_status.so
#LoadModule unique_id_module modules/mod_unique_id.so
LoadModule userdir_module modules/mod_userdir.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule ssl_module modules/mod_ssl.so

ServerAdmin myname@company.com

ServerName MyServer:80

UseCanonicalName Off

DocumentRoot "D:/htdocs"

<Directory />
Options FollowSymLinks
AllowOverride None

<Directory "D:/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all

UserDir "My Documents/My Website"

<IfModule dir_module>
DirectoryIndex index.php index.html index.htm index.php5

<FilesMatch "^\.ht">
Order allow,deny
Deny from all

TypesConfig conf/mime.types

DefaultType text/plain

<IfModule mod_mime_magic.c>
MIMEMagicFile conf/magic

HostnameLookups Off

ErrorLog logs/error.log

LogLevel warn

<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common

<IfModule logio_module>
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
CustomLog logs/access.log common

ServerTokens Full

ServerSignature On

Alias /icons/ "C:/Program Files/Apache Software Foundation/Apache2.2/icons/"

<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all

<IfModule alias_module>
ScriptAlias /cgi-bin/ "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/"

<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all

IndexOptions FancyIndexing VersionSort

AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip

AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*

AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core

AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^

ReadmeName README.html
HeaderName HEADER.html

IndexIgnore .?* *~ *# HEADER* README* RCS CVS *,v *,t

AddLanguage ca .ca
AddLanguage cs .cz .cs
AddLanguage da .dk
AddLanguage de .de
AddLanguage el .el
AddLanguage en .en
AddLanguage eo .eo
AddLanguage es .es
AddLanguage et .et
AddLanguage fr .fr
AddLanguage he .he
AddLanguage hr .hr
AddLanguage it .it
AddLanguage ja .ja
AddLanguage ko .ko
AddLanguage ltz .ltz
AddLanguage nl .nl
AddLanguage nn .nn
AddLanguage no .no
AddLanguage pl .po
AddLanguage pt .pt
AddLanguage pt-BR .pt-br
AddLanguage ru .ru
AddLanguage sv .sv
AddLanguage zh-CN .zh-cn
AddLanguage zh-TW .zh-tw

LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW

ForceLanguagePriority Prefer Fallback

AddCharset ISO-8859-1 .iso8859-1 .latin1
AddCharset ISO-8859-2 .iso8859-2 .latin2 .cen
AddCharset ISO-8859-3 .iso8859-3 .latin3
AddCharset ISO-8859-4 .iso8859-4 .latin4
AddCharset ISO-8859-5 .iso8859-5 .latin5 .cyr .iso-ru
AddCharset ISO-8859-6 .iso8859-6 .latin6 .arb
AddCharset ISO-8859-7 .iso8859-7 .latin7 .grk
AddCharset ISO-8859-8 .iso8859-8 .latin8 .heb
AddCharset ISO-8859-9 .iso8859-9 .latin9 .trk
AddCharset ISO-2022-JP .iso2022-jp .jis
AddCharset ISO-2022-KR .iso2022-kr .kis
AddCharset ISO-2022-CN .iso2022-cn .cis
AddCharset Big5 .Big5 .big5
AddCharset WINDOWS-1251 .cp-1251 .win-1251
AddCharset CP866 .cp866
AddCharset KOI8-r .koi8-r .koi8-ru
AddCharset KOI8-ru .koi8-uk .ua
AddCharset ISO-10646-UCS-2 .ucs2
AddCharset ISO-10646-UCS-4 .ucs4
AddCharset UTF-8 .utf8
AddCharset GB2312 .gb2312 .gb
AddCharset utf-7 .utf7
AddCharset utf-8 .utf8
AddCharset big5 .big5 .b5
AddCharset EUC-TW .euc-tw
AddCharset EUC-JP .euc-jp
AddCharset EUC-KR .euc-kr
AddCharset shift_jis .sjis

DefaultIcon /icons/unknown.gif

DefaultType text/plain

<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin

LoadModule php5_module "c:/Program Files/php/php5apache2_2.dll"
AddType application/x-httpd-php .php .php5


<VirtualHost www.mydomain.com>
ServerName www.mydomain.com
ServerAdmin myname@company.com
DocumentRoot D:/htdocs/www.mydomain.com
ErrorLog D:/logs/mydomain/error_log
TransferLog D:/logs/mydomain/access_log

-------httpd.conf END ------------

Any help will be greatly appreciated, I'm totally new at Apache, but determined to learn...



3:04 pm on Dec 1, 2006 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

To start, I suggest that you read literally every word on this page [httpd.apache.org] and then follow the links for whatever kind of virtual server you want to set up.



8:57 pm on Dec 1, 2006 (gmt 0)

10+ Year Member

Thanks Jim

The documents I've read on apache.org deals with setting up Apache in a Unix environment, except for some few pages with general descriptions for Win32.

I know my httpd.conf file is way too long, from what I've read so far, including O'Reilly's Apache The Definitive Guide, tons of pages from apache.org and other places the basic things to set up in the httpd.conf file is:

DirectoryIndex index.html

ServerRoot has not been changed
Listen (one listen line for each IP number)
DocumentRoot "D:/htdocs/"
LoadModule - the server has been set up by my ISP, and it is working.
ServerAdmin my@email.com
DirectoryIndex index.html index.php (PHP is installed and working)
ServerName 80
<directory D:/htdocs>
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
ServerName www.mydomain.com
ServerAdmin my@email.com
DocumentRoot D:/htdocs/www.mydomain.dk
ErrorLog D:/logs/mydomain/error_log
TransferLog D:/logs/mydomain/access_log

So to begin with I have the following exact questions:

1. DocumentRoot "D:/htdocs/" - Is this a correct way of writing, is " " right?

I have created the map D:\htdocs\ and in it the map www.mydomain.com

2. ServerName - I have 8 IP numbers on the server, but don't know the exact name of the server. From what I understand, the <VirtualHost> part at the end of the .conf file overrules the ServerName stated earlier in the file

3. <directory D:/htdocs> - should I use " " here too?
Do I need to give any rights to the D:\htdocs\ folder. I AM aware that in the conf file I must always use foreward slashes and NOT end htdocs with a /

4. are there any errors (syntax, use of " ", etc.) in this, which according to book and webpages should be correct:
ServerName www.mydomain.com
ServerAdmin my@email.com
DocumentRoot D:/htdocs/www.mydomain.dk
ErrorLog D:/logs/mydomain/error_log
TransferLog D:/logs/mydomain/access_log

I'm not lazy and don't ask for a complete .conf file, I'm willing to learn and work hard learning, I just could not find answers for the above questions anywhere... I'ts very frustrating when things seems to be right, but don't work.


9:51 pm on Dec 1, 2006 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

The double quotation marks are most often used whenever you have spaces in a folder name. It doesn't hurt to leave them there if you don't have any spaces in the path either though.

One thing to remember is that after every change to the httpd.conf file, you must restart the Apache server.

Each VirtualHost container will have it's own DocumentRoot directive. When the user keys in a request to the domain named in the ServerName directive, Apache will find that container and use the directives found there to add to or override any other directives already in existence. The "add to or override" is directive-specific so you'll need to look in the manual pages for each that you have questions.


4:44 pm on Dec 2, 2006 (gmt 0)

10+ Year Member

Thanks Coopster

Yes, I do restart apache after making changes to the httpd.conf file, I'll read some more.

Is it right to assume that there are no errors in the above settings?


2:25 am on Dec 3, 2006 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

It is impossible to tell from here.

Another thing to be aware of is that your browser may be caching pages. Don't forget to clear the cache.


12:17 pm on Dec 5, 2006 (gmt 0)

10+ Year Member

Thanks, I am aware of the browser cache too.

I'll contact my ISP, everything looks 100% ok according to all my sources (websites, books, etc)


1:59 pm on Dec 5, 2006 (gmt 0)

10+ Year Member

Whenever something does not work as expected, have a look at the webserver's log files.

You specified the main server's error file to be:
ErrorLog logs/error.log
Don't know how the apache expands this -- .\logs\error.log?
Perhaps you may look at this first.

Another first debugging step could be to start the apache in a command prompt window to get an impression on a possible config error situation.

If there are no config errors to be seen above, then you may look at the virtual domain's error file
ErrorLog D:/logs/mydomain/error_log

Kind regards,


3:18 pm on Dec 5, 2006 (gmt 0)

10+ Year Member

My error log shows all request errors as requests to:

C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/

The VirtualHost is set to:

<VirtualHost www.mydomain.com>
ServerName www.mydomain.com
ServerAdmin mail@company.com
DocumentRoot "D:/htdocs"
ErrorLog D:/logs/mydomain/error_log
TransferLog D:/logs/mydomain/access_log

The problem is that requesting www.mydomain.com shows the index.html file from C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/
(ping www.domain.com gives the right IP)

I have also tried to change the VirtualHost DocumentRoot "D:/htdocs/www.domain.com".

My ISP can go through the whole system for a charge, but that's the last resort and it don't teach me anything.

Thanks for your patience and continued help!

Added: the D:/logs/mydomain/error_log is empty


4:05 pm on Dec 5, 2006 (gmt 0)

10+ Year Member

Are you saying there aren't any error messages on startup? Fine.
Then the main settings should be OK and you should look at the virtualhost definitions.

<VirtualHost www.mydomain.com>

There is some inconsistency with your definitions. Earlier you had an IP address in the virtualhost statement, now you have a domain name here.
The apache doc says <VirtualHost addr[:port] ...> and shows an IP address in the example, and furthermore says that the argument to the <VirtualHost> directive must exactly match the argument to the NameVirtualHost directive.
So try with a <VirtualHost>.

You may then try to start the apache with the -S, -t or -e switch on the command prompt and see what happens:
Show the settings as parsed from the config file (currently only shows the virtualhost settings).
Run syntax tests for configuration files only. The program immediately exits after these syntax parsing tests with either a return code of 0 (Syntax OK) or return code not equal to 0 (Syntax Error). If -D DUMP_VHOSTS is also set, details of the virtual host configuration will be printed.
-e level
Sets the LogLevel to level during server startup. This is useful for temporarily increasing the verbosity of the error messages to find problems during startup.

If these wouldn't show anything to go after, I am run out of ideas, sorry.

Kind regards,


7:58 pm on Dec 5, 2006 (gmt 0)

10+ Year Member

Thanks Romeo

I changed <VirtualHost www.mydomain.com> to <VirtualHost> and something happened, now it shows "server not working" but it looks like progress as it just took the C:/..../apache2.2/htdocs/index.html

Now it seems like it is moving on to the VirtualHost

I am new to this, but will work on and post my results, thanks again


Featured Threads

Hot Threads This Week

Hot Threads This Month