logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: virtual server not working
Author
bbxrider



Joined: 24 Feb 2007
Posts: 27
Location: stocktown ca

PostPosted: Tue 13 Mar '07 2:57    Post subject: virtual server not working Reply with quote

this is for apache 2.2.4, winxp pro, set up for php
i'm using a vanilla default http.conf, (until now) and added directives for a virtual host, but browser requests for the virtual host domain still comes up with (what i think of as the default or primary domain) default domain page, job1data.com.
i did create the mywarmbeach directory and have an index.htm page there, but am not sure if i have missed or made an error in the directive or need to change some thing else in my http.conf
once this is working do i need anything else for php to also be working in the virtual host domain?
any help much appreciated, thanks bbxrider


<VirtualHost www.mywarmbeach.com>
ServerAdmin bbxrider@job1data.com
DocumentRoot "C:/apache2/htdocs/mywarmbeach/"
DirectoryIndex index.html index.htm
ServerName www.mywarmbeach.com
ServerAlias mywarmbeach.com
ErrorLog C:/apache2/log/www.mywarmbeachcom-error_log
CustomLog C:/apache2/log/www.mywarmbeachcom-access_log
</VirtualHost>
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7306
Location: Germany, Next to Hamburg

PostPosted: Tue 13 Mar '07 9:55    Post subject: Reply with quote

If you only want to reach your domain local you can the edit (notepad) the hosts file from your system.

C:\Windows\system32\drivers\etc\hosts
Code:

127.0.0.1 www.mywarmbeach.com
127.0.0.1 mywarmbeach.com




If it should be reachable from the internet you need a public DNS server.

Hope that helps. If not please ask again.
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Tue 13 Mar '07 15:02    Post subject: Reply with quote

Do you have a NameVirtualHost directive in your httpd.conf file?

NameVirtualHost goes outside the <VirtualHost ...> directives, and it instructs Apache to use ServerName (like www.mywarmbeach.com ) instead of IP addresses (like 127.0.0.1) to select the correct virtual host.

-tom-
Back to top
bbxrider



Joined: 24 Feb 2007
Posts: 27
Location: stocktown ca

PostPosted: Tue 13 Mar '07 20:38    Post subject: virtual host follow up Reply with quote

thank you for the replies
both domains, job1data.com and mywarmbeach.com point to my public ip.
my apache htdocs/index.htm (default from install) is currently served up for both domains
what i'm trying to do, is setup addressing browser to mywarmbeach.com with no slash, etc, and have htdocs/mywarmbeach/index.htm be returned. basically i think of establishing htdocs/mywarmbeach/ as the 'root' direectory for mywarmbeach.com access? did i say that right?
i would like to be able to access from localhost as well.
i did not have the namevirtualhost in my http.conf, but will (attempt) to add that to see if that makes the virtual host directives start working. i take it you need a namevirtualhost and virtualhost directives for each domain you want to serve without having to directly address with domain.com/targetAddr ? and its my understanding i can have apache serve mult domains from the same ip addr, i guess there is a practical limit based on processing capability of server machine and bandwidth available to the server machine. in my case the number of hits will be trivial
Back to top
bbxrider



Joined: 24 Feb 2007
Posts: 27
Location: stocktown ca

PostPosted: Tue 13 Mar '07 21:44    Post subject: virtual host follow up number 2 Reply with quote

i tried this
nameVirtualHost *
<VirtualHost *>
ServerAdmin bbxrider@job1data.com
DocumentRoot "C:/apache2/htdocs/mywarmbeach/"
DirectoryIndex index.html index.htm
ServerName www.mywarmbeach.com
ServerAlias mywarmbeach.com *.mywarmbeach.com
ErrorLog C:/apache2/log/www.mywarmbeach-error_log
# CustomLog C:/apache2/log/www.mywarmbeach-access_log
</VirtualHost>
<VirtualHost *>
ServerAdmin bbxrider@job1data.com
DocumentRoot "C:/apache2/htdocs/"
DirectoryIndex index.html index.htm
ServerName www.job1data.com
ServerAlias job1data.com *.job1data.com
ErrorLog C:/apache2/log/www.job1data-error_log
# CustomLog C:/apache2/log/www.mywarmbeach-access_log
</VirtualHost>
however still not working, seems simple enough from the documentation but obviously i'm missing something. when i restart there are no messages i see flash by in the cmd prmpt window and no error logs
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7306
Location: Germany, Next to Hamburg

PostPosted: Tue 13 Mar '07 22:20    Post subject: Reply with quote

I think there is missing the port. in the containers and in Name vhsot
Also I miss container for the docs root inside

Code:

NameVirtualHost *:80

<VirtualHost *:80>
     ServerAdmin bbxrider@job1data.com
     DocumentRoot "C:/apache2/htdocs/mywarmbeach"
    ServerName apache3.dyndns.org
    ServerAlias www.apache3.dyndns.org
    ErrorLog C:/apache2/log/www.mywarmbeach-error_log
    CustomLog C:/apache2/log/www.mywarmbeach-access_log  common
<Directory "C:/apache2/htdocs/mywarmbeach/">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>


If Apache still does not start
open the console (cmd)
browse (cd) to apache\bin folder
type httpd -e debug -w
{enter}

to check your vhosts you can try httpd -S -w
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Thu 15 Mar '07 17:37    Post subject: Reply with quote

Your config seems like it should work, although technically there should not be trailing slashs in your DocumentRoot directories
- per the DocumentRoot docs.

This, however, is not the cause of your problem.

Please post the results of httpd -S -w as James Blond suggested.

Are your virtual host diretives in the C:\apache2\conf\extra\httpd-vhosts.conf file?
If so - did you remember to uncomment the line:
    # Virtual hosts
    Include conf/extra/httpd-vhosts.conf
in your C:\apache2\conf\httpd.conf file?

-tom-
Back to top
bbxrider



Joined: 24 Feb 2007
Posts: 27
Location: stocktown ca

PostPosted: Thu 15 Mar '07 19:13    Post subject: thanks for your reply Reply with quote

this is my current setup, at least as far as directives for virtual host
they are in my http.conf file not the .....\httpd-vhosts.conf file
is that where should be? i thought it was optional to put them there or http.conf? the include.....vhosts.conf line is commented out, seeing how i put the directives in http.conf

ServerRoot "C:/apache2"
Listen 80
DocumentRoot "C:/apache2/htdocs"
<Directory "C:/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin bbxrider@job1data.com
DocumentRoot C:/apache2/htdocs/mywarmbeach
DirectoryIndex index.html index.htm
ServerName www.mywarmbeach.com
ServerAlias mywarmbeach.com *.mywarmbeach.com
ErrorLog C:/apache2/log/www.mywarmbeach-error_log
# CustomLog C:/apache2/log/www.mywarmbeach-access_log
</VirtualHost>
<VirtualHost *:80>
ServerAdmin bbxrider@job1data.com
DocumentRoot C:/apache2/htdocs/job1data
DirectoryIndex index.html index.htm
ServerName www.job1data.com
ServerAlias job1data.com *.job1data.com
ErrorLog C:/apache2/log/www.job1data-error_log
# CustomLog C:/apache2/log/www.mywarmbeach-access_log
</VirtualHost>

i ran the httpd -S -w for the status of the current virt host setup, it seems to be looking ok?

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server www.mywarmbeach.com (C:/apache2/conf/httpd.conf:228)
port 80 namevhost www.mywarmbeach.com (C:/apache2/conf/httpd.conf:228)
port 80 namevhost www.job1data.com (C:/apache2/conf/httpd.conf:237)
Syntax OK

what i find really strange is that if apache has my default server being mywarmbeach, how come i get the htdocs directory default page for mywarmbeach.com and not the mywarmbeach.com default page? (which of course is in the ..../mywarmbeach directory)
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Thu 15 Mar '07 19:49    Post subject: Reply with quote

Puzzling!

I set up Apache 2.2.4 on Win2k in c:\apache2\ and cut & pasted your virtual host directives into my httpd.conf.
The only difference is my logs go in C:\apache2\logs\ with an "s".
i.e.
    ErrorLog C:/apache2/logs/www.mywarmbeach-error_log
It worked fine for me, so unless it's the log directory name - the problem doesn't seem to be your config
- at least, not the directives that you posted.

-tom-
Back to top
bbxrider



Joined: 24 Feb 2007
Posts: 27
Location: stocktown ca

PostPosted: Thu 15 Mar '07 22:32    Post subject: you da man Reply with quote

thanks, so much, evidently that was it, i just changed the paths to logs instead of log and voila.
can't believe after all the looking, changing, restarting, head scratching and posts that was it. when one time i did not have the path correct for DocumentRoot, the restart complained very clearly.
it seems really strange that the restart didn't complain about this basically wrong path, and the httpd -S status seemed to show everything ok, but in the end, virtual host was not working????????????

btw i used to live in milfah, kindah neahh wuhsta, Smile right on north pond, it was a great setup, boat right there at the dock, when not frozen
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7306
Location: Germany, Next to Hamburg

PostPosted: Thu 15 Mar '07 22:36    Post subject: Reply with quote

httpd -S checks only vhost config! use httpd -t to test the whole config, but vhosts Wink
Back to top


Reply to topic   Topic: virtual server not working View previous topic :: View next topic
Post new topic   Forum Index -> Apache