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: apache 2.2.10 vhost
Author
chillipepper



Joined: 26 Apr 2008
Posts: 22

PostPosted: Tue 18 Nov '08 23:59    Post subject: apache 2.2.10 vhost Reply with quote

Hi all.really hope someone can help me here..
I have 3 sites in my vhost
site1.com
site2.com
site3.com

when i try my local ip to the server 192.162 etc it loads up site1.com ok with runnin scirpts
when i try same thing local i192.168etc/site2.com its loads up fine all html pages an not runnin any scirpts on this 1..
when i try same 192.168etc/site3.com i get forbiddon.i look in the error logs and see options ExecCGI is off in this directory but i know i have it on..site 1 and 3 are runnin the same scirpts and i have set then up the same. does anyone know whats goin on.do i have to put something dif in site3.com to run scirpts aswell and site1.com

#
# 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 Admin@site1.com
DocumentRoot "C:/wwws/forum"
ServerName site1.com
ServerAlias www.site1.com
<Directory "C:/wwws/forum">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin "c:/wwws/forum/Yabb2/cgi-bin/yabb2"
<Directory "c:/wwws/forum/Yabb2/cgi-bin/yabb2">
AllowOverride all
Options +ExecCGI
AddHandler cgi-bin .cgi ,pl
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerAdmin Admin@site2.com
DocumentRoot "C:/wwws/forum/site2.com"
ServerName site2.com
ServerAlias www.site2.com
<Directory "c:/wwws/forum/site2.com/">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</Virtualhost>

<VirtualHost *:80>
ServerAdmin Admin@site3.com
DocumentRoot "C:/wwws/forum/site3.com"
ServerName site3.com
ServerAlias www.site3.com
<Directory "C:/wwws/forum/site3.com">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin "c:/wwws/forum/site3.com/Yabb2/cgi-bin/yabb2"
<Directory "c:/wwws/forum/site3.com/Yabb2/cgi-bin/yabb2">
AllowOverride all
Options +ExecCGI
AddHandler cgi-bin .cgi ,pl
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Back to top
glsmith
Moderator


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

PostPosted: Wed 19 Nov '08 9:49    Post subject: Reply with quote

which one of the three, if any, are configured in the Main section of your httpd.conf file?
Back to top
chillipepper



Joined: 26 Apr 2008
Posts: 22

PostPosted: Wed 19 Nov '08 10:25    Post subject: Reply with quote

none of these are configured in the Main section of httpd.conf file i have left it alone.only thing i done in the httpd.conf is uncomit loadmodule cgi_module/mod_cgi.so and uncomit the Include conf/extra/httpd-vhosts.conf
Back to top
glsmith
Moderator


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

PostPosted: Wed 19 Nov '08 20:45    Post subject: Reply with quote

...and there is where the problem lies.

1st vhost must be duplicate of the main host. It's in the docs, just not easily found and is the #1 cause of problems when first getting vhosts to work.

Code:
<VirtualHost _default_:80>
ServerName main.server.name
DocumentRoot "/path/to/main/server/docroot
</VirtualHost>
Back to top
chillipepper



Joined: 26 Apr 2008
Posts: 22

PostPosted: Thu 20 Nov '08 11:16    Post subject: Reply with quote

well i did what was said.and now no sites work..not found Rolling Eyes but before site 1 was default site and that loaded up just by ip..also site did load up as site2.com even site3.com tryed to run..now i get nothin
Back to top
chillipepper



Joined: 26 Apr 2008
Posts: 22

PostPosted: Thu 20 Nov '08 16:11    Post subject: Reply with quote

after hours of messin about.default loads up the one that comes with apache say Its works!
also the site which is runnin just html page..but now am gettin this error in logs about other 2 site which are runnin my scripts..options ExecCGI is off in this directory..whay am i gettin this on both sites now.before it was only on my site3.com
why cant i run scripts with vhost
Back to top
glsmith
Moderator


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

PostPosted: Thu 20 Nov '08 23:08    Post subject: Reply with quote

It depends on the setup

I think the multiple script aliases are confusing .. there should only be one server wide one in my experience. Also if the AddHandler in the main server config for cgi is enable, it works server wide and is not needed in every single vhost.

and since you have (comma)pl in your AddHandlers, (dot)pl scripts should actually show the code, not error. Then again I think you should see an error about it in the error log.

###############################################

NameVirtualHosts *:80

#main host _default_ duplicate here
<VirtualHost _default_:80>
ServerName main.server.name
DocumentRoot "/path/to/main/server/docroot
</VirtualHost>


#site one
<VirtualHost *:80>
ServerAdmin Admin@site1.com
DocumentRoot "C:/wwws/forum"
ServerName site1.com
ServerAlias www.site1.com

# Default permissions for c:/www/forum/*/*/*/*/*/*/*/* -> off to infinity within this vhost
<Directory "C:/wwws/forum">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

# Add/override only anything needed, no need for the rest as it is covered in above Directory container
<Directory "c:/wwws/forum/Yabb2/cgi-bin/yabb2">
# Override the AllowOverride None above
AllowOverride all
#Add option to execute scripts
Options +ExecCGI
</Directory>
</VirtualHost>


#Site 2
<VirtualHost *:80>
ServerAdmin Admin@site2.com
DocumentRoot "C:/wwws/forum/site2.com"
ServerName site2.com
ServerAlias www.site2.com
<Directory "C:/wwws/forum/site2.com">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</Virtualhost>


# Site 3
<VirtualHost *:80>
ServerAdmin Admin@site3.com
DocumentRoot "C:/wwws/forum/site3.com"
ServerName site3.com
ServerAlias www.site3.com
<Directory "C:/wwws/forum/site2.com">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory "c:/wwws/forum/site3.com/Yabb2/cgi-bin/yabb2">
AllowOverride all
Options +ExecCGI
</Directory>
</Virtualhost>

###############################################

Site one and three will only allow execution in
c:/wwws/forum/Yabb2/cgi-bin/yabb2
c:/wwws/forum/site3.com/Yabb2/cgi-bin/yabb2

Site 2 no execution period


Just remember that anything done in

C:/path/to/this/directory, will work same from that point out
C:/path/to/this/directory/1/2/3/4/5/6/7/8/9/add-nauseam


Anything outside a vhost container is server wide, anything inside is for that vhost only.
Back to top
chillipepper



Joined: 26 Apr 2008
Posts: 22

PostPosted: Tue 25 Nov '08 13:19    Post subject: Reply with quote

right i copy this last conf you posted..but am still gettin no whare.
i look i error logs same things keep comein up..
when i put 192.168.2.10/site1.com it seems to look in the default path the look for folder site1.com its dont seem to look at vhost where it would say to look c:/wwws/forum/site1.com
am lost here.just dont know whats goin on
Back to top
glsmith
Moderator


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

PostPosted: Tue 25 Nov '08 18:50    Post subject: Reply with quote

OK, well it doesn't work quite that way. Your config, and mine, assumes you have those sites configured in the windows hosts file of the computer you are trying to view the sites from.

c:\windows\system32\drivers\etc\hosts

"hosts" is the name of the file with no extension.
Look in the file, you will see

127.0.0.1 localhost

you add:
192.168.2.10 site1.com site2.com site3.com
192.168.2.10 www.site1.com www.site2.com www.site3.com


then from this computer you just
http://site1.com
http://site2.com
http://site3.com


Last edited by glsmith on Thu 27 Nov '08 0:46; edited 1 time in total
Back to top
chillipepper



Joined: 26 Apr 2008
Posts: 22

PostPosted: Wed 26 Nov '08 0:49    Post subject: Reply with quote

1st i want to say is thank you for all the help you are given me..I feel we are 1 step closer still some isues

1) when am workin on server box..i can get site2.com and site3.com to work but site1.com only loads up default page (its Works) and not my site.

2) if i go onto my lappy and try to view sites none of them show up only default am try Http://192.168.2.10/site1.com etc only site show is default when 192.168.2.10

sorry about this
Back to top
glsmith
Moderator


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

PostPosted: Wed 26 Nov '08 1:49    Post subject: Reply with quote

no problem, you will have to do that to every hosts fie on every computer you try from.

You are using hostnames, computers do not understand them, only IP addresses. So for the Internet world wide we have domain names and DNS, that translate www.apachelounge.com into it's numerical IP address. In homes, if we do not want the problem of setting up DNS, we just make entries into the hosts files.

I use a little of both. I have DNS for my .com/net/org/info's and I have host file entries for things I do not want public. For instance, PPHMyAdmin
http://phpmyadmin.server

Host file:
192.168.5.25 phpmyadmin.server

Now my computer knows where to look and Apache resolves the name cause it is sent in the host headers by the browser. This is the key, the host headers sent by the browser that Apache reads. At
http://192.168.2.10/site1.com, the host header your browser is sending is simply 192.168.2.10, which does not match the vhosts configured therefor it just serves the default host, the main server.

I have one host file sitting on my server (not the servers actual one) that I make changes to. I've scheduled each other computer (and server as well) to copy this one hosts file into the computer (which ever one it is) into place at boot up. That way, I make one change and eventually every computer picks up the changes.

This hosts file is read often by the DNS Client in Windows XP+, in Windows 2000, it is only read once, on boot up, so in Win2k you have to reboot after making changes.

Bottom line is, without the host files being modified, you computer will NOT understand site1/2/3.com, and apache will only understand http://192.168.2.10/site1.com as

C:/Apache2/htdocs/site1.com
C:/Apache2/htdocs/site2.com
C:/Apache2/htdocs/site3.com

providing you main host is located at C:/Apache2/htdocs
Back to top
chillipepper



Joined: 26 Apr 2008
Posts: 22

PostPosted: Wed 26 Nov '08 2:17    Post subject: Reply with quote

so for me to acess my sites over network i need to add an host file
so i go to c:/apache/hhdocs and make folder site1.com and then open notepad and add 192.168.2.10/site1.com what do i save it as..hostfile.txt
I seem to understand abit what yr sayin but not to sure what to do.
Back to top
glsmith
Moderator


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

PostPosted: Wed 26 Nov '08 5:08    Post subject: Reply with quote

No ..

leave Apache configured as it is

In each computer, edit those host fies and add in

192.168.2.10 site1.com site2.com site3.com www.site1.com www.site2.com www.site3.com

all on one line or multiline

192.168.2.10 site1.com www.site1.com
192.168.2.10 site2.com www.site2.com
192.168.2.10 site3.com www.site3.com

those are all the vhosts you have configure in Apache.
Back to top
chillipepper



Joined: 26 Apr 2008
Posts: 22

PostPosted: Wed 26 Nov '08 14:21    Post subject: Reply with quote

I can tell you guys here at apache lounge that it should be you the ones the should write the docs on apache.In the pass i look at the docs and could not understand fully.but here at apache lounge you guys do help us understand better.

back to my very little prob.I feel we are almost there..Coooooooooooool
From how i read your last 2 post is that if i want to access over my network i need to add a other host file but on my lappy now..which is runnin xp pro.so it can send the right header to my server.I cant seem to find the host file on my lappy to add this info.

Just so i understand all this host thingy lol..if my sites was live and my domain names been reg then dns been sorted to my ip..then i dont need to add a host file on my lappy i just use www.domain name.com...am i right thinkin this that need host file on lappy over network so snd right header and not need for host file on lappy if site are live on net.. Very Happy
Back to top
glsmith
Moderator


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

PostPosted: Wed 26 Nov '08 19:58    Post subject: Reply with quote

chillipepper said;

my lappy now..which is runnin xp pro.so it can send the right header to my server.I cant seem to find the host file on my lappy to add this info


C:\Windows\System32\Drivers\etc\hosts

"Just so i understand all this host thingy lol..if my sites was live and my domain names been reg then dns been sorted to my ip..then i dont need to add a host file on my lappy i just use www.domain name.com"

Yes, as long as your router supports what is called "loopback" and it seems the majority do.

"...am i right thinkin this that need host file on lappy over network so snd right header and not need for host file on lappy if site are live on net.."

Yes, host file is not needed if you have real domains, DNS and the router supports loopback.
Back to top
chillipepper



Joined: 26 Apr 2008
Posts: 22

PostPosted: Thu 27 Nov '08 1:53    Post subject: Reply with quote

again thank you glsmith

all the help you have gave me.

Yep am petty sure loopback should work as i can get default site show up on lappy..but others dont show..i did look on lappy at the hosts and saw 5 files in there which are host1.BAK FILE lmhost.SAM File networks protocol and services
tryed to put

192.168.2.10 site1.com www.site1.com
192.168.2.10 site2.com www.site2.com
192.168.2.10 site3.com www.site3.com
in the host1 bak file and got no joy then i tryed the same in imhost still no joy..and yet i did reboot after save..
i think i just have to get afew domian names a do it over net..live..
Back to top
glsmith
Moderator


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

PostPosted: Thu 27 Nov '08 2:19    Post subject: Reply with quote

On laptop, open that hosts1.bak and save as "hosts"

no extension, reboot, give her a try
Back to top
chillipepper



Joined: 26 Apr 2008
Posts: 22

PostPosted: Fri 28 Nov '08 0:28    Post subject: Reply with quote

yep try that still no joy Confused but i did settup up an domain name to check if 1 of my vhost site works and yes it work just how i wanted..still abit pee off that only way to veiw these sites is only live..this means i have to settup all domains so i can work on them over network..not idea but at lease it something..so big thank you for the help..
Back to top


Reply to topic   Topic: apache 2.2.10 vhost View previous topic :: View next topic
Post new topic   Forum Index -> Apache