LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Apache2 - need help with virtual hosts (http://www.linuxquestions.org/questions/linux-software-2/apache2-need-help-with-virtual-hosts-472798/)

bioalchemist 08-10-2006 10:21 PM

Apache2 - need help with virtual hosts
 
I have apache2 running on Debian Etch and it's working fine. What I'm trying to do is to point 2 different hosts to 2 different directories using the default file found in /etc/apache2/sites-available/ directory. I have 2 sites: blog.mysite.com and photos.mysite.com and I have it configured so that blog.mysite.com points to /var/www/serendipity/ while photos.mysite.com points to /usr/share/gallery2

So here's the funny part: When I open up a browser and type in photos.mysite.com, it comes back with the main.php page like it should (except the picture icons are missing), but none of the links work - they ALL give a 404 error.

Similarly, when I type in blog.mysite.com, the same thing happens. Page displays (without formatting - it's all messed up, but it displays so it's obvious that it's going to the correct directory), but any links you click on inside the page reveals a 404 error. Any ideas?

Oh, and I know these pages work fine because I was using an alias in my default file previously and everything was fine. Thanks!

j-ray 08-11-2006 02:20 AM

are the paths to the links that dont show relative to the index.html/index.php or whatever? Are there "index" files in your sites? There are a lot of ways to build websites so i think you could post some more info...
if there are "index" files point your browser exactly to their address and see whether this changes something. I experienced that this might make a difference in the past.
cheers,j.

rahulk 08-11-2006 02:42 AM

can you paste me the httpd.conf content where you have defined these two virtualhosts??

bioalchemist 08-11-2006 09:09 AM

Quote:

Originally Posted by j-ray
are the paths to the links that dont show relative to the index.html/index.php or whatever? Are there "index" files in your sites? There are a lot of ways to build websites so i think you could post some more info...
if there are "index" files point your browser exactly to their address and see whether this changes something. I experienced that this might make a difference in the past.
cheers,j.

The file that is supposed to be shown is called "main.php" for the gallery one, and I'm not sure what it is for the blog. I'm using Serendipity, if that helps any. It almost seems like the main.php page points to a stylesheet or something that is not getting read. I can point my browser directly at that and I get the same result.

However if I add an alias to the default file from /etc/apache2/sites-available/

Alias /gallery /usr/share/gallery2

and then type this in the browser: photos.mysite.com/gallery everything works perfectly. Same with the blog.

bioalchemist 08-11-2006 09:26 AM

Quote:

Originally Posted by rahulk
can you paste me the httpd.conf content where you have defined these two virtualhosts??

Since I'm using Apache2, the httpd.conf file is used only for backward compatability, so it's an empty file. In Apache 2, the virtual hosts are defined in the default file that is located in /etc/apache2/. I made modifications to the original one and I've also tried reading in the Apache documentation and trying to create my own. Nothing seems to work, but here is the contents of the default file:

Code:

NameVirtualHost 192.168.3.10:80

<VirtualHost 192.168.3.10:80>
    DocumentRoot /usr/share/gallery2
    ServerName photos.mysite.com
    ServerAdmin me@gmail.com
    <Directory />
          Options FollowSymLinks
          AllowOverride None
    </Directory>
    ErrorLog /var/log/apache2/error.log
    LogLevel warn
    CustomLog /var/log/apache2/access.log combined
    ServerSignature On

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

  Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

<VirtualHost 192.168.3.10:80>
    DocumentRoot /var/www/serendipity
    ServerName blog.mysite.com
    ServerAdmin me@gmail.com
    <Directory />
          Options FollowSymLinks
        AllowOverride None
    </Directory>
    ErrorLog /var/log/apache2/error.log
    LogLevel warn
    CustomLog /var/log/apache2/access.log combined
    ServerSignature On

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

  Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

Alias /webmail /usr/share/squirrelmail


bioalchemist 08-11-2006 02:24 PM

Problem Solved! Had nothing to do with Apache - both Gallery and Serendipity needed configuration changes to get them to work correctly. Thanks for the replies!


All times are GMT -5. The time now is 08:39 PM.