Link to home
Start Free TrialLog in
Avatar of keefe007
keefe007

asked on

Include Virtual not working correctly in Apache 2.2

I recently migrated to a new server with apache2.2 and php 5.x.  Now I'm having problems with a few scripts that used to work fine under apache1.3 and php 4.x.

The problem boils down to the php virtual() function and the html include virtual function.

Here's what is happening:

<?php virtual("/test/"); ?> - doesn't work

<?php virtual("/test/index.html"); ?> - works fine

Both of these worked fine on the last server running apache1.x.

Why isn't apache2 able to find the index file and include it?

Thanks!
Avatar of administradores
administradores

Hello

Is the directory index set correctly in your conf?

DirectoryIndex index.html
This also for php.

DirectoryIndex index.html index.php
Avatar of keefe007

ASKER

DirectoryIndex is set correctly and loading http://www.domain.com/test/ results in the correct index being displayed.
I should add:

<!--#include virtual="/test/"--> - doesn't work
<!--#include virtual="/test/index.html"--> - works fine
The problem appears to be with your particular install and not Apache2 in general.  I was able to test out your scenario on my install (Apache2 and PHP5 running on XP) and it worked as expected.  Can you post your httpd.conf file?
I did and worked too.

#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2> for detailed information.
# In particular, see 
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.  
 
ServerRoot "/etc/httpd"
Listen 80
 
#LoadModule php4_module /usr/lib/apache/libphp4.so 
LoadModule php5_module /usr/lib/apache/libphp5.so 
#LoadModule suphp_module /usr/lib/apache/mod_suphp.so
LoadModule php5_module        /usr/lib/apache/libphp5.so
 
User apache
Group apache
 
ServerAdmin username@mydomain.com
DocumentRoot "/var/www/html"
 
<Directory /home/*>
    AllowOverride All
    Options -MultiViews -Indexes +FollowSymlinks +Includes
<Limit GET POST OPTIONS PROPFIND>
    Order allow,deny
    Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
    Order deny,allow
    Deny from all
</LimitExcept>
</Directory>
 
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
 
<Directory "/var/www/html">
    Options Indexes FollowSymLinks Includes
    AcceptPathInfo On
    AllowOverride None
    Order allow,deny
    Allow from all
   <IfModule mod_suphp.c>
        suPHP_Engine On
        suPHP_UserGroup webapps webapps
   </IfModule>
</Directory>
 
<IfModule dir_module>
    DirectoryIndex index.html index.htm index.shtml index.php index.php5 index.php4 index.php3 index.phtml index.cgi
</IfModule>
 
<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>
 
ErrorLog /var/log/httpd/error_log
LogLevel debug
 
<IfModule log_config_module>
    #replace %b with %O for more accurate logging
    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
      LogFormat "%h %l %u %t \"%r\" %>s %O" common
      LogFormat "%O" bytes
 
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>
 
    CustomLog /var/log/httpd/access_log common
</IfModule>
 
<IfModule alias_module>
    # Include some DirectAdmin alias
    Include conf/extra/httpd-alias.conf
</IfModule>
 
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>
 
DefaultType text/plain
 
<IfModule mime_module>
    # This is needed for PHP
    Include conf/extra/httpd-php-handlers.conf
 
    TypesConfig conf/mime.types
    AddType application/x-gzip .tgz
    AddEncoding x-compress .Z
    AddEncoding x-gzip .gz .tgz
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddHandler cgi-script .cgi
    AddHandler type-map var
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>
 
#EnableMMAP off
#EnableSendfile off
 
#######################################################################################
# Do not change anything in included files, because they are rewritten by DirectAdmin #
#######################################################################################
 
# Server-pool management (MPM specific)
Include conf/extra/httpd-mpm.conf
 
# Multi-language error messages
Include conf/extra/httpd-multilang-errordoc.conf
 
# Fancy directory listings
Include conf/extra/httpd-autoindex.conf
 
# Language settings
Include conf/extra/httpd-languages.conf
 
# User home directories
#Include conf/extra/httpd-userdir.conf
 
# Real-time info on requests and configuration
Include conf/extra/httpd-info.conf
 
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
 
# Local access to the Apache HTTP Server Manual
#Include conf/extra/httpd-manual.conf
 
# Distributed authoring and versioning (WebDAV)
Include conf/extra/httpd-dav.conf
 
# Various default settings
Include conf/extra/httpd-default.conf
 
# Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.conf
 
# Deflate module settings
Include conf/extra/httpd-deflate.conf
 
# All the DirectAdmin vhosts
Include conf/extra/directadmin-vhosts.conf
 
# All suPHP directives
Include conf/extra/httpd-suphp.conf
 
# All the other includes needed by the custombuild script
Include conf/extra/httpd-includes.conf
 
#######################################################################################
# End of included files that are rewritten by DirectAdmin                             #
#######################################################################################
 
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
 
# Alias for RoundCube webmail
Alias /roundcube /var/www/html/roundcube/

Open in new window

I've been testing this in /var/www/html/ but have also tested in /home/
The only thing that pops out at me in the http.conf file is that you're loading php5_module twice.  I'm pretty sure this isn't the culprit though.  Nothing else in this file indicates a problem.  I tried to replicate the issue with my install and I couldn't.  This file does load other external files that may have information that could lead you to the answer.  The file says that you shouldn't modify those files directly:

# Do not change anything in included files, because they are rewritten by DirectAdmin #

I'm not familiar with DirectAdmin....
Could you please post also the includes, because there must be some missconfig there, since i tryed with a Redhat server and also with windows and everything worked fine.

Also as i understand you're in a production server isn't?
Thanks for the comment darron_chapman.  I did take that extra call to php5 out but as you expected it didn't have any effect.

I was able to do further troubleshooting and it appears the problem lies in the mod_deflate config.  I started commenting the includes out one by one and found that everything works when mod_deflate is disabled.  Here's what that conf looks like:
   1.
      #
   2.
      # Required modules: mod_deflate
   3.
      #
   4.
      # Please see the documentation at
   5.
      # <URL:http://httpd.apache.org/docs/2.2/mod/mod_deflate.html>
   6.
      # for further details before you try to setup deflate module.
   7.
      #
   8.
       
   9.
      <Location />
  10.
      # Insert filter
  11.
      SetOutputFilter DEFLATE
  12.
       
  13.
      # Netscape 4.x has some problems...
  14.
      BrowserMatch ^Mozilla/4 gzip-only-text/html
  15.
       
  16.
      # Netscape 4.06-4.08 have some more problems
  17.
      BrowserMatch ^Mozilla/4\.0[678] no-gzip
  18.
       
  19.
      # MSIE masquerades as Netscape, but it is fine
  20.
      BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  21.
       
  22.
      # Don't compress images and other uncompressible content
  23.
      SetEnvIfNoCase Request_URI \
  24.
       \.(?:gif|jpe?g|png|rar|zip|exe)$ no-gzip dont-vary
  25.
       
  26.
      # Make sure proxies don't deliver the wrong content
  27.
      Header append Vary User-Agent env=!dont-vary
  28.
      </Location>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of administradores
administradores

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial