Solved

Include Virtual not working correctly in Apache 2.2

Posted on 2007-11-21
13
1,332 Views
Last Modified: 2013-11-18
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!
0
Comment
Question by:keefe007
  • 6
  • 5
  • 2
13 Comments
 
LVL 5

Expert Comment

by:administradores
ID: 20331320
Hello

Is the directory index set correctly in your conf?

DirectoryIndex index.html
0
 
LVL 5

Expert Comment

by:administradores
ID: 20331330
This also for php.

DirectoryIndex index.html index.php
0
 

Author Comment

by:keefe007
ID: 20331342
DirectoryIndex is set correctly and loading http://www.domain.com/test/ results in the correct index being displayed.
0
 

Author Comment

by:keefe007
ID: 20331354
I should add:

<!--#include virtual="/test/"--> - doesn't work
<!--#include virtual="/test/index.html"--> - works fine
0
 
LVL 19

Expert Comment

by:darron_chapman
ID: 20331492
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?
0
 
LVL 5

Expert Comment

by:administradores
ID: 20331712
I did and worked too.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:keefe007
ID: 20331960

#

# 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

0
 

Author Comment

by:keefe007
ID: 20331968
I've been testing this in /var/www/html/ but have also tested in /home/
0
 
LVL 19

Expert Comment

by:darron_chapman
ID: 20332156
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....
0
 
LVL 5

Expert Comment

by:administradores
ID: 20332863
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.

0
 
LVL 5

Expert Comment

by:administradores
ID: 20332866
Also as i understand you're in a production server isn't?
0
 

Author Comment

by:keefe007
ID: 20334237
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

0
 
LVL 5

Accepted Solution

by:
administradores earned 500 total points
ID: 20349550
Hello keefe007

I could reproduce the same error and the problem are the php files, and guessed it must be a mod_header bug but not sure, and researched a bit and found 2 tickets about the same error.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43939

If php files are ignored the error is gone, and with html there are no errors.






24.\.(?:gif|jpe?g|png|rar|zip|exe|php)$ no-gzip dont-vary

Open in new window

0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now