由 wben 在 10-10-2003 04:06 发表:
httpd -- Virtual Host Problem
I have only one computer, whose operating system is redhat 9.0. I wanted to try DNS Server and Httpd. But I meet a weird problem when I set virtual host on httpd. The following is the content that I knew:
I set my compute host name "dream", the IP address "130.130.130.1" and domain name is "mynet.com". and also I configured my DNS server. The following is what my DNS file (The mynet.com.zone file)
$TTL 86400
@ IN SOA dream. root.localhost (
23 ; serial
28800 ; refresh
7200 ; retry
604800 ; expire
86400 ; ttl
)
IN NS 130.130.130.1.
IN NS dream.
ccc IN A 130.130.130.2
dream IN A 130.130.130.1
test IN CNAME dream
www IN CNAME dream
vhost IN CNAME dream
I used "dig test.mynet.com"
; <<>> DiG 9.2.1 <<>> test.mynet.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 63284
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 0
;; QUESTION SECTION:
;test.mynet.com. IN A
;; ANSWER SECTION:
test.mynet.com. 86400 IN CNAME dream.mynet.com.
dream.mynet.com. 86400 IN A 130.130.130.1
;; AUTHORITY SECTION:
mynet.com. 86400 IN NS dream.
mynet.com. 86400 IN NS 130.130.130.1.
;; Query time: 24 msec
;; SERVER: 130.130.130.1#53(130.130.130.1)
;; WHEN: Sat Oct 4 14:34:11 2003
;; MSG SIZE rcvd: 114
So I assumed that my DNS works fine.
First I tried "http://localhost", I got "Test Page", which means my Apache Server works fine. Then, I tried "http://dream", it also gave my "Test Page", which is also reasonable, since it is my host default name. So I configured the httpd, I created a name virtual host -- vhost, the following is some contents of httpd.conf file.
Use name-based virtual hosting.
NameVirtualHost 130.130.130.1
Where do we put the lock and pif files?
LockFile "-"
CoreDumpDirectory "/etc/httpd"
Defaults for virtual hosts
Logs
Virtual hosts
Virtual host Default Virtual Host
1<virtualhost *="">
2
3ServerSignature email
4
5DirectoryIndex index.php index.html index.htm index.shtml
6
7
8
9<ifdefine have_ssl="">
10</ifdefine>
11
12
13
14LogLevel debug
15
16HostNameLookups off
17
18
19
20
21
22</virtualhost>
Virtual host test
1<virtualhost 130.130.130.1="">
2
3DocumentRoot /var/vvv/
4
5
6
7ServerAdmin wben@localhost
8
9ServerName vhost.mynet.com
10
11
12
13ServerSignat</virtualhost>