|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Something is wrong with virtual hosts
Hello, i have a problem with virtual hosts. I am running debian 5 with apache 2. In /etc/apache2/sites-available i have a default configuration and one for a virtual host. Both enabled. The default looks like this:
Code:
NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@localhost
DocumentRoot /some/path
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /some/path/>
Options -Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
And there's a virtualhost, configured like this: Code:
#
# domain.com (/path/)
#
<VirtualHost *>
ServerAdmin webmaster@localhost
ServerName www.domain.com
ServerAlias domain.com *.domain.com
DocumentRoot /path/
<Directory /path/>
AllowOverride All
</Directory>
# CGI Directory
ScriptAlias /cgi-bin/ /path/cgi-bin/
<Location /cgi-bin>
Options +ExecCGI
</Location>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog /var/log/apache2/access.domain.log combined
</VirtualHost>
It works if i navigate to *.domain.com, but if i navigate to domain.com precisely - it shows me the default website from the default config. I've defined "domain.com" in aliases so why doesn't it work ? |
|
#2
|
||||
|
||||
|
Do you have the dns and host files set up propperly.
And this <virtualhost *> should be <virtualhost *:80> and namevirtualhost * should be namevirtualhost *:80 |
|
#3
|
|||
|
|||
|
I've just changed all to *:80 format. No change unfortunatelly. Still doesn't work without a domain prefix.
What did you mean by dns and host files? Content of /ec/hosts Code:
127.0.0.1 localhost.localdomain localhost 127.0.0.1 mgrsoft.domain.com # Auto-generated hostname. Please do not remove this comment. ?.?.?.? domain.com domain domain Question marks simply hide the ip. Last edited by murklys : June 3rd, 2009 at 11:06 AM. |
|
#4
|
||||
|
||||
|
Here is my setup, but will not work if you do not have a registered domain name.
Code:
#Apache2
UserDir www
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@phpshelf.net
DocumentRoot /home/menator/www
ServerName www.phpshelf.net
ScriptAlias /cgi-bin/ "/home/menator/www/cgi-bin/"
CustomLog /home/menator/logs/access_log combined
</VirtualHost>
#/etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 server1.phpshelf.net localhost.localdomain localhost
192.168.1.103 server1.phpshelf.net server1
::1 localhost6.localdomain6 localhost6
#named.conf
#
# Configure ourself as the host for basiczone.com
#
zone "phpshelf.net" IN {
type master;
file "phpshelf.net.zone";
};
#
zone "1.168.192.in-addr.arpa" {
type master;
file "192.168.1.rev";
};
# zone file
$TTL 900 ; 900 seconds default record (T)ime (T)o (L)ive in cache
; Authored by SilentRage
;
; Download Location:
; http://www.dollardns.net/bind/
@ SOA ns1 ( ; ns1.basiczone.com is the primary server for basiczone.com
postmaster ; contact email for basiczone.com is postmaster@basiczone.com
2004041700 ; Serial ID in reverse date format
21600 ; Refresh interval for slave servers
1800 ; Retry interval for slave servers
604800 ; Expire limit for cached info on slave servers
900 ) ; Minimum Cache TTL in zone records
@ NS ns1 ; ns1.basiczone.com is a host for basiczone.com
@ NS ns2 ; ns2.basiczone.com is a host for basiczone.com
@ A 192.168.1.103 ; basiczone.com's IP address is 127.0.0.4
@ MX 10 mail ; Mail for *@basiczone.com is sent to mail.basiczone.com
ns1 A 192.168.1.103 ; ns1.basiczone.com's IP address is 127.0.0.1
ns2 A 192.168.1.103 ; ns2.basiczone.com's IP address is 127.0.0.2
mail A 192.168.1.103 ; mail.basiczone.com's IP address is 127.0.0.3
phpshelf.net. A 192.168.1.103
www A 192.168.1.103 ; www.basiczone.com's IP address is 127.0.0.4
Hope it helps I do not have a great deal of knowledge with apache and dns but this is how I got mine to work. Apache documentation was a great help |
|
#5
|
|||
|
|||
|
Well my domains are located in another place and another dns servers, they simply point to this server's IP. According to tutorials on google, my config should be working ... I don't see much of a difference between your config and mine. But still can't get a domain without www to work ... I guess i'll try google's help once again. If only i knew how to name this particular problem ... Now it's like looking for a needle in a haystack.
|
|
#6
|
||||
|
||||
|
Two questions
Do you have access to the dns server " the zone file "? When was the zone file updated? It takes 72 hours for it to flow out to the web. |
|
#7
|
|||
|
|||
|
If it weren't updated - i wouldn't see the default page of my server
I wouldn't resolve to the correct ip at all. It gets to the server and then ... for some reason ... doesn't understand it has to go to the virtual host directory. |
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > Something is wrong with virtual hosts |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|