LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache2 VirtualHost Syntax OK but domain still doesn't work (http://www.linuxquestions.org/questions/linux-server-73/apache2-virtualhost-syntax-ok-but-domain-still-doesnt-work-636021/)

bg108 04-17-2008 10:55 AM

Apache2 VirtualHost Syntax OK but domain still doesn't work
 
Hi,

I'm trying to add another virtual host for my apache2 server (running on Gentoo Linux) and it doesn't work eventhough apache2ctl -S shows syntax OK....I have around 5 VirtualHost on my apache2 server and they are working fine, but when I try to add another virtualhost it doesn't work (browser says cannot display page)

Here is a part of my vhost config files

<VirtualHost *:80>
ServerName fgo.laolao.com
DocumentRoot "/home/webhost/bizware"
</VirtualHost>

<VirtualHost *:80>
ServerName logostore.laolao.com
DocumentRoot "/home/webhost/bizdata/logoStore"
</VirtualHost>

Above shows 2 virtual host configurations, the first one fgo.laolao.com is working, however the second one logostore.laolao.com doesn't work....


Please help,
THanks

custangro 04-17-2008 11:02 AM

I may be wrong, but I think that using this twice might be the problem.

Code:

<VirtualHost *:80>
I have always put the IP address instead of the *

Like so

Code:

<VirtualHost 192.168.2.1:80>
Hope this helps

-C

datopdog 04-17-2008 11:11 AM

The "*:80" is not a problem is simply means that apache will respond to all the interfaces on the server for that vhost.

You need to setup an error and access log for the vhost and then take a look at what apache is logging.

I suspect 2 things could cause that.

1. The app running in the document root has errors
2. Apache cannot search the path due to permission settings being incorrect, for apache to be able to server content all the directores above need to have the -x bit set.

bg108 04-17-2008 11:23 AM

Quote:

Originally Posted by datopdog (Post 3124262)
The "*:80" is not a problem is simply means that apache will respond to all the interfaces on the server for that vhost.

You need to setup an error and access log for the vhost and then take a look at what apache is logging.

I suspect 2 things could cause that.

1. The app running in the document root has errors
2. Apache cannot search the path due to permission settings being incorrect, for apache to be able to server content all the directores above need to have the -x bit set.

1. The app running in the document root has NO errors because it's just a simple html file with HELLO output string
2. Permission to document root folder and above folders are fine, I can access document root folder by going though bizdata.laolao.com/logoStore but logostore.laolao.com doesn't work

datopdog 04-17-2008 12:08 PM

It will not hurt to turn on logging to see actually what is going on.

what is the output of
Code:

apache2 -D DUMP_VHOSTS
do you see the server with the correct root named there

bg108 04-17-2008 05:32 PM

Quote:

Originally Posted by datopdog (Post 3124319)
It will not hurt to turn on logging to see actually what is going on.

what is the output of
Code:

apache2 -D DUMP_VHOSTS
do you see the server with the correct root named there


I've already turned on the logging, but no error, like I said vhost configuration syntax is ok

billymayday 04-17-2008 06:15 PM

Do you have a NameVirtualHost directive before these declarations?

Along the lines of what tatopgog was pushing, can you swap these two declartations around and confirm that it's the first that works not just fgo?

anomie 04-17-2008 07:20 PM

Quote:

Originally Posted by billymayday
Do you have a NameVirtualHost directive before these declarations?

Bingo. Without it these are IP-based virtual hosts...

bg108 04-18-2008 10:23 AM

Quote:

Originally Posted by anomie (Post 3124681)
Bingo. Without it these are IP-based virtual hosts...

Yes, I put NameVirtualHost directive at the beginning of the file....here is my vhost config file


NameVirtualHost *:80
NameVirtualHost *:443

<Directory "/home/hosting">
AllowOverride None
Order allow,deny
Allow from all
</Directory>

<VirtualHost *:80>
ServerName fgo.laolao.com
DocumentRoot "/home/hosting/bbware"
</VirtualHost>

<VirtualHost *:80>
ServerName logostore.laolao.com
DocumentRoot "/home/hosting/bbdata/logoStore"
</VirtualHost>


Like I said, fgo.laolao.com is working but not logostore.laolao.com. Is there anything else that could make this happen ? I just started working at this company and this apache2 server was configured by previous Administrator, and I'm new to apache too. Is there some place else in Apache server that could explicitly define to allow DNS recognizing fgo.insightrix.com ?

bg108 04-18-2008 11:12 AM

Hi,

After doing searching around, I think my problem is I need to configure DNS server probably (Gentoo Linux). Could anyone show me steps by steps of how to configure DNS server ?

billymayday 04-18-2008 12:26 PM

Maybe this will help http://www.linuxhomenetworking.com/w...onfiguring_DNS

Before you do that though, try adding fgo.laolao.com and logostore.laolao.com to the hosts file of whatever machine you are testing from to make sure that's the issue. No point going through all that setup to find it doesn't fix your problem.

Two simple lines should do it (don't deleted what's there already) - say the apache server's IP is 1.2.3.4

/etc/hosts

existing (something like)

127.0.0.1 localhost.localdomain localhost

plus new

1.2.3.4 fgo.laolao.com
1.2.3.4 logostore.laolao.com

Did you try reversing the entries for virtualhosts?

bg108 04-18-2008 12:54 PM

Quote:

Originally Posted by billymayday (Post 3125424)
Maybe this will help http://www.linuxhomenetworking.com/w...onfiguring_DNS

Before you do that though, try adding fgo.laolao.com and logostore.laolao.com to the hosts file of whatever machine you are testing from to make sure that's the issue. No point going through all that setup to find it doesn't fix your problem.

Two simple lines should do it (don't deleted what's there already) - say the apache server's IP is 1.2.3.4

/etc/hosts

existing (something like)

127.0.0.1 localhost.localdomain localhost

plus new

1.2.3.4 fgo.laolao.com
1.2.3.4 logostore.laolao.com

Did you try reversing the entries for virtualhosts?

Thanks very much guys, I finally got it working, I had to do something with DNS binding...Specifically I added an entry for "logostore" into the file host.zone under /var/bind

Thanks again


All times are GMT -5. The time now is 09:17 AM.