Apache virtual hosts

Discuss Applications
User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main »

I don't want access but your "NameVirtualHost" and "<VirtualHost xxx>" names have to be associated with the address on your server's network interface, not your public IP address. So use "<VirtualHost 10.10.0.1>" if that is your server's real offnet address (address that shows up on the interface when you do a "/sbin/ifconfig").

User avatar
cdhgold
administrator
administrator
Posts: 382
Joined: Tue Mar 18, 2003 6:11 pm
Location: Texas

Post by cdhgold »

i changed the * to the local ip and restarted apache but still am getting the same result

chris

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main »

And you also changed the "NameVirtualHost"? I also notice you are using strange naming conventions, like a one part domain name. I don't know if that's screwing things up (addicted2tech with no second part like com, net, org, home, etc). I see it in your /etc/hosts, your /etc/resolv.conf, your "ServerName" directive at the top of your httpd.conf. It may work but I have never seen anyone do it that way. I think it's illegal (not in accordance with the RFCs) but I could be wrong on that. Just never seen it.

EDIT: I also noticed you didn't create a "<Directory xxx>" section for the second host. Find the '<Directory "/srv/www/htdocs">' section and make a copy of it but the second one should point to the directory of your second virtual host.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main »

I wonder now if it's not the "UseCanonicalName" statement. Yours is set to "On" and I think it might have to be set to "Off" to use name based virtual hosts. Again, I could be wrong on this but it's worth a shot.

Actually, run this command and it should tell you what it doesn't like about the config:

/usr/sbin/httpd -S

If your apache server isn't /usr/sbin/httpd then use whatever path to your apache executable that is appropriate for your system.

User avatar
cdhgold
administrator
administrator
Posts: 382
Joined: Tue Mar 18, 2003 6:11 pm
Location: Texas

Post by cdhgold »

here is the output of trying to run the command you asked for I have also made the canonical name settings change you suggested as well as adding the document root entry no go yet.

jose:/etc/init.d # ./apache2 -S
Usage: ./apache2 <command> <server flags>

where <command> is one of:
start - start httpd
startssl - start httpd with -DSSL
stop - stop httpd (sendign SIGTERM to parent)
try-restart - stop httpd and if this succeeds (i.e. if
it was running before), start it again.
status - check whether httpd is running
restart - stop httpd if running; start httpd
restart-hup - restart httpd if running by sending SIGHUP,
or start if not running
reload|graceful - do a graceful restart by sending a SIGUSR1 or
start if not running
configtest - do a configuration syntax test
extreme-configtest - try to run httpd as nobody (detects more errors
by actually loading the configuration, but cannot
read SSL certificates)
probe - probe for the necessity of a reload, give
out the argument which is required for a reload.
(by comparing conf files with pidfile timestamp)
full-server-status - dump a full status screen; requires lynx or w3m
and mod_status enabled
server-status - dump a short status screen; requires lynx or w3m
and mod_status enabled
help - this screen

optional server flags are passed through to httpd.

jose:/etc/init.d # ./apache2 configtest
Syntax OK

Chris

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main »

Actually that's not the command I wanted you to run. You need to find the actual Apache executable. I don't know what that is called in a SUSE installation but on a Red Hat installation it's called /usr/sbin/httpd. You should be able to find it inside that apache2 init script.

If that doesn't reveal anything you might want to check your Apache "error_log" file or your /var/log/messages for any indication of a problem. I don't know why this is being so difficult. It usually takes me like 5 seconds to configure up a virutual host in apache.

User avatar
cdhgold
administrator
administrator
Posts: 382
Joined: Tue Mar 18, 2003 6:11 pm
Location: Texas

Post by cdhgold »

i found the command you wanted it is/usr/sbin/htpd2 -S and it checked virtual host syntax and said it is okay. i know this shoud not be that difficult. I have tried to set everything as it should be according to apache web site and your advice. but still getting primary web site showing up under www.triplecandb.com

any other ideas?
Chris

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main »

Add a separate log file to both Virtual hosts:

In one put:

ErrorLog /var/log/httpd/addicted2tech-error_log
CustomLog /var/log/httpd/addicted2tech-access_log common

and in the other put

ErrorLog /var/log/httpd/triplecandb-error_log
CustomLog /var/log/httpd/triiplecandb-access_log common

Then restart and try and access both and see if you get any logging information in both.

And check the original error_log for any indication of a problem.

User avatar
cdhgold
administrator
administrator
Posts: 382
Joined: Tue Mar 18, 2003 6:11 pm
Location: Texas

Post by cdhgold »

consider it done taking a break from t/s to relax with my wife will post log ouput later

thanks again void,
chris

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main »

Yeah, this one is giving me a headache. :)

User avatar
cdhgold
administrator
administrator
Posts: 382
Joined: Tue Mar 18, 2003 6:11 pm
Location: Texas

Post by cdhgold »

would you be willing to access my sytem and help me figure this out .. i'm afraid my lack of knowledge is what is keeping us from solving this and would like for another set of eyes to check it out.

chris

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main »

Check your PM.

User avatar
cdhgold
administrator
administrator
Posts: 382
Joined: Tue Mar 18, 2003 6:11 pm
Location: Texas

Post by cdhgold »

read it and replied

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main »

Ok, I got it working. It helps if we edit the proper httpd.conf file. ;) It seems SUSE uses /etc/apache2 conf directory rather than /etc/httpd so we weren't even editing the proper files. That's OK though, I got a default config to work with. I like the way SUSE lays things out. Here's what I did. I created a directory for each web site under /srv/www/vhosts:

/srv/www/vhosts/www.addicted2tech.com

and

/srv/www/vhosts/www.triblecandb.com

Now all of the configuration for each vhost is done in their own separate file. I made a copy of /etc/apache2/vhosts.d/vhost.template called:

/etc/apache2/vhosts.d/www.addicted2tech.com.conf

and modified it accordingly. Did the same for

/etc/apache2/vhosts.d/www.triplecandb.com.conf

Look those files over. The only other thing I had to do was add a "NameVirtualHost *:80" to /etc/apache2/listen.conf and reload apache.

I never could get in via ssh so I strugged through webmin (ewwwww). :)

So now if you want to add more virtual hosts just add another vhost.conf in the vhosts.d directory and create a document directory under /src/www/vhosts like the others. You might want to make sure everything got copied over and clean up where you used to have this stuff so it doesn't waste hard drive space (you have like two or three copies of all of your web content in various places).

Let me know if something isn't working.

P.S. You might want to think about turning on SSL for your webmin.

User avatar
cdhgold
administrator
administrator
Posts: 382
Joined: Tue Mar 18, 2003 6:11 pm
Location: Texas

Post by cdhgold »

Void i can't thank you enough . the triple site is my wife's and you have been a HUGE help!! if you are interested and have the disk space on your ftp i'll be happy to upload ISOs of suse 9.0. thanks again i'm looking forward to looking over the files in detail to learn more from them thanks again. I did try to install SSL for webmin but ran into an error that I have not had time to go over due to working on this issue.

Chris

Post Reply