LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 10-13-2006, 02:31 PM   #1
Stuart Morrow
LQ Newbie
 
Registered: Oct 2006
Location: Ireland.
Distribution: Various distros
Posts: 5

Rep: Reputation: 0
Unhappy Virtual Hosts in apache2-2.2.0-21 not working


Virtual hosts in apache2-2.2.0-21 don't work correctly. Instead, any request to the server defaults to one vhost regardless of the hostname used to call it.

My /etc/apache2/vhosts.d/intranet.conf:
Code:
<VirtualHost intranet:80>
    ServerAdmin stuart@intranet
    ServerName intranet

    DocumentRoot /srv/www/vhosts/intranet

    ErrorLog /var/log/apache2/intranet-error_log
    CustomLog /var/log/apache2/intranet-access_log combined

    # Needed for name-based vhosts.
    UseCanonicalName Off

    ServerSignature On

    # This also does DirectoryIndex index.php, so I don't need to worry about
    # DirectoryIndex'es:
    Include /etc/apache2/conf.d/php5.conf

    ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"

    ErrorDocument 404 "/srv/www/vhosts/intranet/404.php"

    <Directory "/srv/www/vhosts/intranet">
        Options Indexes FollowSymLinks
        AllowOverride None
        Allow from 10.0.1.*
    </Directory>
</VirtualHost>
My /etc/apache2/vhosts.d/stumo.dyndns.org.conf:
Code:
<VirtualHost *:80>
    ServerAdmin stuart@stumo.dyndns.org
    ServerName stumo.dyndns.org

    DocumentRoot /srv/www/vhosts/stumo.dyndns.org

    ErrorLog /var/log/apache2/stumo.dyndns.org-error_log
    CustomLog /var/log/apache2/stuno.dyndns.org-access_log combined

    # don't loose time with IP address lookups
    HostnameLookups Off

    # needed for named virtual hosts
    UseCanonicalName Off

    # configures the footer on server-generated documents
    ServerSignature On

    # Optionally, include *.conf files from /etc/apache2/conf.d/
    # For example, to allow execution of PHP scripts:
   # Include /etc/apache2/conf.d/mod_php4.conf
    # or, to include all configuration snippets added by packages:
     Include /etc/apache2/conf.d/*.conf
    # /etc/apache2/conf.d/php5.conf does a DirectoryIndex index.php,
    # so I don't need to worry about putting DirectoryIndices in this file

    # There was a load of waffle (# commented) here about what ScriptAlias is, I removed it because comments don't make any difference and 
    # I didn't want to take up ten lines of space of crap not about virtual hosts, in a forum thread about virtual hosts.
    ScriptAlias /cgi-bin/ "/srv/www/vhosts/stumo.dyndns.org/cgi-bin/"

    # More waffle.
    <Directory "/srv/www/vhosts/stumo.dyndns.org/cgi-bin">
        AllowOverride None
        Options +ExecCGI -Includes
        Order allow,deny
        Allow from all
    </Directory>

    # Irrelevant waffle about UserDir stuff.
    
    <Directory "/srv/www/vhosts/stumo.dyndns.org">
        # More waffle.
        Options Indexes FollowSymLinks

        # More waffle here.
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
Other stuff:
The server is behind NAT.
The server's own actual hostname is intranet (I just thought that that may be what is affecting this, since the files that it serves up are always from the /srv/www/vhosts/intranet/ directory, irrespective of whether it's called using the name 'intranet' or the name 'stumo.dyndns.org' or the name '10.0.1.34'.)

But anyway, I quite hope that someone here can figure this out, that would be great, and if you need to see any other files like the main httpd.conf or any other file to try to solve this, then just ask or whatever.
 
Old 10-13-2006, 04:21 PM   #2
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 197Reputation: 197
And I'm assuming you've setup DNS to also point to these new virtual hosts? Looking at your config though, if you have a server defined in the main portion of the conf file, it's always usually necessary to place all the domains and virtual domains as a vritualhost as well.

Also, be sure to restart apache after the changes are made.

But if your trying to get to intranet.dyndns.org and stumo.dyndns.org and only have DNS and one VirtualHost that points to stumo.dyndns.org, well then, that's normal behaviour.
 
Old 10-14-2006, 02:59 AM   #3
Stuart Morrow
LQ Newbie
 
Registered: Oct 2006
Location: Ireland.
Distribution: Various distros
Posts: 5

Original Poster
Rep: Reputation: 0
Nevermind, it occurred to me to try changing he <VirtualHost intranet:80> to <VirtualHost *:80>, and to remove the NameVirtualHost intranet:80 out of my listen.conf, and it now works, which is brilliant.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
apache2 virtual hosts issue Geminias Linux - Networking 0 10-08-2006 03:23 PM
Apache2 - need help with virtual hosts bioalchemist Linux - Software 5 08-11-2006 01:24 PM
Subdomains on Apache2 with virtual hosts - how? <Ol>Origy Linux - Networking 2 08-18-2005 05:53 AM
Apache2, SSL, 2 Virtual Hosts franticbob Linux - Software 0 04-07-2004 09:48 PM
apache2 virtual hosts viniosity Linux - Software 4 02-07-2004 12:15 AM


All times are GMT -5. The time now is 03:54 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration