Results 1 to 5 of 5
hi again. i'm using fedora core 6 and apache 2.2. i'm trying to setup a virtual host. i got my http://www.mysite.com and i'm trying to host http://dept.mysite.com . the web ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 03-21-2007 #1
name-based virtual hosting
hi again. i'm using fedora core 6 and apache 2.2. i'm trying to setup a virtual host. i got my http://www.mysite.com and i'm trying to host http://dept.mysite.com. the web directory of www.mysite.com is in /var/www/html. on the other hand, the directory of dept.mysite.com is in /home/dept/public_html. i've configured my httpd.conf and when i try to access both websites via a browser using the same server, dept.mysite.com opens the page found in the directory of www.mysite.com. i already specified in the httpd.conf the correct directory of dept.mysite.com. may i know what could have caused this? thanks.
btw, if you got any tutorials on this, please let me know.
- 03-21-2007 #2
have you tried the search here
http://www.linuxforums.org/forum/search.php
I know I have personally responded to several of these.
and then there is google (hint, the first link in the google search is apache 1.3, the second 2.)
http://www.google.com/search?q=name+...ient=firefox-a
- 03-23-2007 #3
i still got the same problem. /var/www/html is the default website directory for www.mysite.com. /home/test/public_html is the directory for a site to be hosted in the same machine which is test.mysite.com.
here's my httpd.conf file for the virtual host:
<IfModule mod_userdir.c>
#UserDir disable
UserDir public_html
</IfModule>
NameVirtualHost 192.168.200.1:80
<VirtualHost 192.168.200.1:80>
ServerName localhost
DocumentRoot /var/www/html
DirectoryIndex index.html index.shtml index.php index.htm
</VirtualHost>
<VirtualHost 192.168.200.1:80>
ServerName localhost
ServerAlias test
DocumentRoot /home/test/public_html/test.mysite.com
ErrorLog /var/log/httpd/test_error_log
CustomLog /var/log/httpd/test_access_log common
DirectoryIndex index.html index.shtml index.htm
<Directory "/home/test/public_html">
Options Indexes FollowSymLinks Includes
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
i also configured /etc/hosts:
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost.localdomain localhost
192.168.200.1 www.mysite.com www
127.0.0.1 test.mysite.com
i got 2 different index.htm pages for the two sites. but still whenever i browse http://test.mysite.com, the index page for www.mysite.com appears. i also tried changing
127.0.0.1 testmysite.com
to
192.168.200.1 test.mysite.com
in the hosts file.
is there something wrong with the conf file? thanks guys...
- 03-23-2007 #4
compare the bold parts to the link
http://httpd.apache.org/docs/2.0/vhosts/name-based.html
the server names need to be different if you want them to work differently
Originally Posted by aenguillo
- 03-23-2007 #5
ok, i changed that already. now my problem is whenever i browse them, they open the home pages of the other directory(site). i mean they switched. www.mysite.com opens the index.htm of test.mysite.com and vice versa. it's kinda weird. what i did is i changed the ServerName directive to www.mysite.com and activated canonical names:
UseCanonicalName Onsame results still. directories were switched. i turned canonical names off but nothing happened.
i also noticed this, when i use another computer to browse the sites, only www.mysite.com is viewable (the contents of test.mysite.com is shown). on the other hand, i receive a cannot display webpage error in IE 7 when i browse test.mysite.com
thanks for replying and helping me with this. and i have a follow up question on the bottom part.
here again is my httpd.conf file including the corrections and the added configs:
ServerName www.mysite.com
UseCanonicalName On
DocumentRoot "/var/www/html"
<IfModule mod_userdir.c>
#UserDir disable
UserDir public_html
</IfModule>
NameVirtualHost 192.168.200.1:80
<VirtualHost 192.168.200.1:80>
ServerName www.mysite.com
DocumentRoot /var/www/html
DirectoryIndex index.html index.shtml index.php index.htm
</VirtualHost>
<VirtualHost 192.168.200.1:80>
ServerName test.mysite.com
ServerAlias test
DocumentRoot /home/test/public_html/test.mysite.com
ErrorLog /var/log/httpd/test_error_log
CustomLog /var/log/httpd/test_access_log common
DirectoryIndex index.html index.shtml index.htm
<Directory "/home/test/public_html">
Options Indexes FollowSymLinks Includes
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
i also configured /etc/hosts:
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost.localdomain localhost
192.168.200.1 www.mysite.com www
127.0.0.1 test.mysite.com
====follow up question=====
i haven't seen this in the tutorials i used. but should i be configuring this part of httpd conf too?
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
#<Directory /home/*/public_html>
# AllowOverride FileInfo AuthConfig Limit
# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
# <Limit GET POST OPTIONS>
# Order allow,deny
# Allow from all
# </Limit>
# <LimitExcept GET POST OPTIONS>
# Order deny,allow
# Deny from all
# </LimitExcept>
#</Directory>


Reply With Quote
