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 Hosts - Fixed (See final entry)
Author
OldManRiver



Joined: 21 Jun 2006
Posts: 21

PostPosted: Sat 01 Dec '07 19:28    Post subject: Virtual Hosts - Fixed (See final entry) Reply with quote

All,

have the following in my VH section of httpd.conf, but not working on localhost machine:

Code:
NameVirtualHost *:80

<VirtualHost *:80>
    ServerName davisoft-aec.com
    ServerAlias davisoft-aec.com *.davisoft-aec.com
    DocumentRoot "E:/Local Files/HTML Files/New Home/Site"
</VirtualHost>

<VirtualHost *:80>
    ServerName U-local.com
    ServerAlias U-local.com *.U-local.com
    DocumentRoot "E:/Zips & Downloads/Linux/Ubuntu"
</VirtualHost>

<VirtualHost *:80>
    ServerName manuals.com
    ServerAlias manuals.com *.manuals.com
    DocumentRoot "E:/Manuals"
</VirtualHost>


What am I doing wrong?

Thanks!

OMR


Last edited by OldManRiver on Wed 05 Dec '07 21:04; edited 1 time in total
Back to top
James Blond
Moderator


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

PostPosted: Sat 01 Dec '07 19:36    Post subject: Reply with quote

you may edit the hosts file with notepad

C:\WINDOWS\system32\drivers\etc\hosts

add
Code:

127.0.0.1    davisoft-aec.com
127.0.0.1    U-local.com
127.0.0.1    manuals.com



That works only locally.
Back to top
OldManRiver



Joined: 21 Jun 2006
Posts: 21

PostPosted: Sat 01 Dec '07 23:11    Post subject: Reply with quote

James Blond wrote:
you may edit the hosts file with notepad

C:\WINDOWS\system32\drivers\etc\hosts

add
Code:

127.0.0.1    davisoft-aec.com
127.0.0.1    U-local.com
127.0.0.1    manuals.com



That works only locally.


Thought this was done in Apache in the httpd.conf file?

OMR
Back to top
OldManRiver



Joined: 21 Jun 2006
Posts: 21

PostPosted: Sat 01 Dec '07 23:14    Post subject: 2 Working Reply with quote

All,

Added this code

Code:
Listen 80
Listen 90

NameVirtualHost *:90

<VirtualHost *:90>
    ServerName davisoft-aec.com
    ServerAlias davisoft-aec.com *.davisoft-aec.com
    DocumentRoot "E:/Local Files/HTML Files/New Home/Site"
</VirtualHost>


And now the first 2 work, but still having problems with the last 2.

Have to call second one with "localhost:90"

OMR
Back to top
James Blond
Moderator


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

PostPosted: Sat 01 Dec '07 23:17    Post subject: Reply with quote

That is that your PC know which IP it has to ask if you call that domain name. If not your PC asks the next DNS server which IP is behind that name. And the outside DNS servers don't know your hosts inside.
The vhosts in httpd.conf let apache know which domain it has and which documents are for that domain.

Hope you understand my bad english Rolling Eyes
Back to top
OldManRiver



Joined: 21 Jun 2006
Posts: 21

PostPosted: Sun 02 Dec '07 22:27    Post subject: Reply with quote

James Blond wrote:
That is that your PC know which IP it has to ask if you call that domain name. If not your PC asks the next DNS server which IP is behind that name. And the outside DNS servers don't know your hosts inside.
The vhosts in httpd.conf let apache know which domain it has and which documents are for that domain.

Hope you understand my bad english Rolling Eyes


James,

Think I understand some. Not sure about syntax so giving the following code for the "hosts" file:
Code:
127.0.0.1  localhost, domain1, domain2, domain3

Right now I have it:
Code:
127.0.0.1:80  localhost
127.0.0.1:81  domain1
etc.


Which is right?

OMR
Back to top
James Blond
Moderator


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

PostPosted: Mon 03 Dec '07 10:33    Post subject: Reply with quote

AFAIK the second one is right.
Back to top
PipoDeClown



Joined: 20 Dec 2005
Posts: 77

PostPosted: Tue 04 Dec '07 0:51    Post subject: Reply with quote

u cant have portnumbers in your hosts file
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Tue 04 Dec '07 1:33    Post subject: Reply with quote

Actually, it's


127.0.0.1 localhost domain1 domain2 domain3

No ports, no commas
Back to top
OldManRiver



Joined: 21 Jun 2006
Posts: 21

PostPosted: Tue 04 Dec '07 18:44    Post subject: Reply with quote

glsmith wrote:
Actually, it's


127.0.0.1 localhost domain1 domain2 domain3

No ports, no commas


GLS,

But when I do that all I get is the actual localhost directory, for each def instead of each showing it's own directory and/or default/index page.

What else needs changing to make this work right?

OMR
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Tue 04 Dec '07 21:41    Post subject: Reply with quote

Well . .I've found that you need to have one VHost that is basically a duplicate of the main host part of the config.
So, whatever is the first "ServerName" and it's directory need to be repeated in the VHosts section.

So for instance, If the main document root is say
c:\www\somedir\public

then for my first virtual host I use

<VirtualHost _default_:80>
DocumentRoot c:/www/somedir/public
</VirtualHost>

This becomes a catchall domain when the host name being used is not known by Apache (or someone uses http://xxx.xxx.xxx.xxx (your IP) so I would suggest not duplicating an actuall website unless you want stray requests going to it.


#Main Section
ServerName some.domain.com
DocumentRoot c:/www/somedir/public
<Directory c:/www/somedir/public>
Optiions Whatever
AllowOverride Whatever
Order whatever
<?Directory>


#VHosts Section
NameVirtualHosts:80

<VirtualHost _default_:80>
DocumentRoot c:/www/somedir/public
</VirtualHost>

<VirtualHost *:80>
ServerName www.mydomain.com
DocumentRoot c:/www/mydomain/public_html
..
..
</VirtualHost>

<VirtualHost *:80>
ServerName www.myotherdomain.com
DocumentRoot c:/www/myotherdomain/public_html
..
..
</VirtualHost>

etc. etc.
Back to top
OldManRiver



Joined: 21 Jun 2006
Posts: 21

PostPosted: Wed 05 Dec '07 1:41    Post subject: Actual Code Reply with quote

Here is the actual code from the httpd.conf file:
Code:
#Listen 12.34.56.78:80
Listen 80

# 'Main' server configuration
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot "E:/Local Files"
UseCanonicalName Off

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order Allow,Deny
    Allow from all
</Directory>

<Directory "E:/Local Files">
    Options Indexes FollowSymLinks
    AllowOverride all
    Order Allow,Deny
    Allow from all
</Directory>

UserDir "D:/Program Files/Wamp/Apache2/users/"
DirectoryIndex default.php default.php3 default.html default.htm default.html.var default.shtml index.php index.php3 index.html index.htm index.html.var index.shtml
AccessFileName .htaccess

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

# VHost Section
NameVirtualHost *:80

<VirtualHost localhost:80>
   ServerName localhost
   DocumentRoot "E:/Local Files"
</VirtualHost>

<VirtualHost *:80>
    ServerName davisoft-aec.com
    ServerAlias davisoft-aec.com *.davisoft-aec.com
    DocumentRoot "E:/Local Files/HTML Files/New Home/Site"
</VirtualHost>

<VirtualHost *:80>
    ServerName u-local.com
    ServerAlias u-local.com *.u-local.com
#    ServerPath /domain
    DocumentRoot "E:/Zips & Downloads/Linux/Ubuntu"
</VirtualHost>

<VirtualHost *:80>
    ServerName manuals.com
    ServerAlias manuals.com *.manuals.com
    DocumentRoot "E:/Manuals"
</VirtualHost>


This code currently causes all sessions:

1. http://localhost/
2. http://davisoft-aec.com/
3. http://u-local.com/
4. http://manuals.com/

To all display the directory of the localhost, since that directory contains no "default" or "index" file to autoload.

I have played with this where I can get 1 and 2 up, but 403 errors on 3 & 4, but that is the best I've done so far.

OMR
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Wed 05 Dec '07 4:33    Post subject: Reply with quote

403 error?

Do you have a

<Directory "E:/Zips & Downloads/Linux/Ubuntu">
Options whatever
AllowOverride whatever
Order Allow,Deny
Allow from all
</Directory>

and

<Directory "E:/Manuals">
Options whatever
AllowOverride whatever
Order Allow,Deny
Allow from all
</Directory>


The ...
<Directory "E:/Local Files">
Options whatever
AllowOverride whatever
Order Allow,Deny
Allow from all
</Directory>
... in the main config covers the first 2 since they are both in "E:\local files" which leave the other two to fend for themselves. This should spit a line in your error log similar to "Client not allowed by configuration".
??

and try going from <VirtualHost localhost:80> to <VirtualHost *:80>
just to get things on an even keel


On another more IMHO note. I have a problem with "AllowOverride All"

Allowing an Options override allows a 3rd party to turn on ExecCGI. This could potentially be problematic on Win32 where you do not have suexec and UIDs and all that fun stuff. Anyone can roam through the server with the greatest of ease with the user permissions of Apache which by default are rather impressive. Call me paranoid! In your case no biggie, on a live server however not a good practice. IMHO of course.
Back to top
OldManRiver



Joined: 21 Jun 2006
Posts: 21

PostPosted: Wed 05 Dec '07 21:03    Post subject: Fixed - Problem Defined Reply with quote

Very Happy
glsmith,

Your comment about AllowOverride all did the trick.

Just as soon as I commented out those lines it all started working.

I see you can only use this command on the primary PDC domain and nothing else.

Thanks for the tip!

Kudos!!
Very Happy Rolling Eyes Very Happy Laughing Laughing Exclamation
Back to top


Reply to topic   Topic: Virtual Hosts - Fixed (See final entry) View previous topic :: View next topic
Post new topic   Forum Index -> Apache