You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by al...@schnarff.com on 2007/02/23 18:36:14 UTC

[users@httpd] DirectoryIndex Not Working w/PHP on 2.0.58

I've got a FreeBSD 5.4-RELEASE box that I've just fallen into 
administering, with an existing Apache 2.0.58 install. One of my first 
tasks has been to get PHP4 installed, so that the site can support a 
blog and some other features.

The PHP installation went smoothly, as I did it via FreeBSD's ports 
tree. Phpinfo() shows a healthy install, and the blog functions 
great...except for the fact that it relies on index.php being served up 
for a given directory, which is not working.

Having run into this problem before, I went off and added "index.php" 
to the global DirectoryIndex, which now looks like:

DirectoryIndex index.html index.html.var index.php

When this didn't work (I'm still getting a directory listing instead of 
the output of index.php when I hit 
http://www.myserver.com/subdirectory/), I figured it might have 
something to do with the fact that the domain in question was being 
served out of a VirtualHost directive. So I went in and tweaked the 
DirectoryIndex value for the virtual host, so that it is now:

     DirectoryIndex index.html index.html.var index.asp index.php

(The index.asp piece is because this site was earlier migrated from an 
IIS box; those files are actually just pure HTML in this case.)

Note that I've also got:

AddType application/x-httpd-php .php

in my global config, and PHP pages will parse properly when called directly.

Even with all this done, I'm still getting directory listings instead 
of the output of index.php. At this point, I'm baffled. The only thing 
I can think of is that there's lots of modules loaded, and perhaps one 
of them is conflicting with another somehow.

In any case, here are those modules, as well as the relevant 
VirtualHost config:

LoadModule access_module libexec/apache2/mod_access.so
LoadModule auth_module libexec/apache2/mod_auth.so
LoadModule auth_anon_module libexec/apache2/mod_auth_anon.so
LoadModule auth_dbm_module libexec/apache2/mod_auth_dbm.so
#LoadModule auth_digest_module libexec/apache2/mod_auth_digest.so
#LoadModule file_cache_module libexec/apache2/mod_file_cache.so
LoadModule charset_lite_module libexec/apache2/mod_charset_lite.so
#LoadModule cache_module libexec/apache2/mod_cache.so
#LoadModule disk_cache_module libexec/apache2/mod_disk_cache.so
LoadModule include_module libexec/apache2/mod_include.so
LoadModule deflate_module libexec/apache2/mod_deflate.so
LoadModule log_config_module libexec/apache2/mod_log_config.so
LoadModule logio_module libexec/apache2/mod_logio.so
LoadModule env_module libexec/apache2/mod_env.so
LoadModule mime_magic_module libexec/apache2/mod_mime_magic.so
LoadModule cern_meta_module libexec/apache2/mod_cern_meta.so
LoadModule expires_module libexec/apache2/mod_expires.so
LoadModule headers_module libexec/apache2/mod_headers.so
LoadModule usertrack_module libexec/apache2/mod_usertrack.so
LoadModule unique_id_module libexec/apache2/mod_unique_id.so
LoadModule setenvif_module libexec/apache2/mod_setenvif.so
LoadModule proxy_module libexec/apache2/mod_proxy.so
LoadModule proxy_http_module libexec/apache2/mod_proxy_http.so
<IfDefine SSL>
LoadModule ssl_module libexec/apache2/mod_ssl.so
</IfDefine>
LoadModule autoindex_module libexec/apache2/mod_autoindex.so
LoadModule mime_module libexec/apache2/mod_mime.so
LoadModule dav_module libexec/apache2/mod_dav.so
LoadModule status_module libexec/apache2/mod_status.so
LoadModule asis_module libexec/apache2/mod_asis.so
LoadModule info_module libexec/apache2/mod_info.so
LoadModule cgi_module libexec/apache2/mod_cgi.so
LoadModule dav_fs_module libexec/apache2/mod_dav_fs.so
LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
LoadModule negotiation_module libexec/apache2/mod_negotiation.so
LoadModule imap_module libexec/apache2/mod_imap.so
LoadModule actions_module libexec/apache2/mod_actions.so
LoadModule speling_module libexec/apache2/mod_speling.so
LoadModule userdir_module libexec/apache2/mod_userdir.so
LoadModule alias_module libexec/apache2/mod_alias.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
#LoadModule php4_module libexec/apache2/libphp4.so
#LoadModule php5_module        libexec/apache2/libphp5.so
LoadModule php4_module        libexec/apache2/libphp4.so
LoadModule dir_module libexec/apache2/mod_dir.so

...

<VirtualHost *:80>
     ServerAdmin peabody@wayback.com
     DocumentRoot /usr/local/www/data
     ServerName webdav.marssociety.org
     DirectoryIndex index.html index.html.var index.asp index.php
     ErrorLog /var/log/webdav-error_log
     CustomLog /var/log/webdav-access_log combined
     <Location /mdrs>
      AuthName "MDRS WebDav"
      AuthType Basic
      AuthUserFile /usr/local/etc/apache2/users
       DAV On
       AllowOverride None
       Options None
       <Limit PUT POST DELETE PROPFIND PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
         Require user peabody, gus
       </Limit>
    </Location>

# To take acre of attenpts at relay spamming? The domain
# always seems to be fem.to. Or I could use SQUID in the pattern as well
    RewriteEngine On
    RewriteCond %{HTTP:VIA} fem\.to [NC]
    RewriteRule ^.*$ - [F]
</VirtualHost>

Any help at all would be greatly appreciated.

Alex Kirk


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] DirectoryIndex Not Working w/PHP on 2.0.58

Posted by al...@schnarff.com.
> Highly unlikely that this is a bug.  Much more likely that you have
> another DirectoryIndex directive someplace in httpd.conf, an Include'd
> config file, or an .htaccess that is overriding your setting.

Ding ding ding! We have a winner!

There was a conflicting DirectoryIndex in an included config file that 
I had missed earlier. Tweak that, reload Apache, and *poof*! It came 
right up.

Thanks for the assistance, and sorry to bother everyone with such a 
dumb question.

Alex


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] DirectoryIndex Not Working w/PHP on 2.0.58

Posted by Joshua Slive <jo...@slive.ca>.
On 2/23/07, alex@schnarff.com <al...@schnarff.com> wrote:
> > Interesting, Usually the things you define in the Vhost sections can
> > indeed be overridden in other places. Espcially "server wide" Aliases
> > that live in some other conf file.
> > Is it just one particular subdirectory that you have this issue with?
>
> Nope, it's for any directory whose sole index is an "index.php".
>
> > It could well be a particular module, does a bug search for this version
> > of apache/php come up with anything.
>
> Not sure...where should I check?
>
> > I suppose you are stuck with this
> > and cant update?
>
> Not easily. I'm just starting to take over this box, and so I'm not
> 100% certain of everything I even have to check when doing an update.
> I'm working on it, though, trust me. :-P

Highly unlikely that this is a bug.  Much more likely that you have
another DirectoryIndex directive someplace in httpd.conf, an Include'd
config file, or an .htaccess that is overriding your setting.  If you
rename the index.php to index.html does it come up?  If you then
replace the DirectoryIndex line with DirectoryIndex foobar.html, does
the index.html continue to be shown?  That would be definitive proof
that you have another DirectoryIndex someplace overriding your config.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] DirectoryIndex Not Working w/PHP on 2.0.58

Posted by al...@schnarff.com.
> Interesting, Usually the things you define in the Vhost sections can
> indeed be overridden in other places. Espcially "server wide" Aliases
> that live in some other conf file.
> Is it just one particular subdirectory that you have this issue with?

Nope, it's for any directory whose sole index is an "index.php".

> It could well be a particular module, does a bug search for this version
> of apache/php come up with anything.

Not sure...where should I check?

> I suppose you are stuck with this
> and cant update?

Not easily. I'm just starting to take over this box, and so I'm not 
100% certain of everything I even have to check when doing an update. 
I'm working on it, though, trust me. :-P

> (I have had weird problems with mod_dav on many
> occasions, but its only a wild guess) my advice would be temporarily
> comment out modules not absolutely needed, and comment them in
> gracefully restarting each time until the issue returns.

...which was my plan for dealing with other issues on the box.

> Sorry to be stumpled!

Not your fault, I appreciate you trying. I just hope someone else on 
the list has a clue about what's going on here.
>
> On one more unrelated point do you really want this:
>
>       <Limit PUT POST DELETE PROPFIND PROPPATCH MKCOL COPY MOVE LOCK
> UNLOCK>
>         Require user peabody, gus
>       </Limit>
>
> which essentially says dont require valid user for GET and the others
> not listed, I only mention it in case because it would be more easily
> said like this:
> | <LimitExcept GET>
> |  Require user peabody, gus
> | </LimitExcept>
>
> to which you could add a smaller list of _allowed_ methods so I just
> wondered if it was what was intended.
>
> |If you want to require a valid user whatever the method then dont
> bother with the limit statement.

I'll have to talk to the people actually using WebDAV, but that sounds 
like a good idea. :-)

Alex


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] DirectoryIndex Not Working w/PHP on 2.0.58

Posted by matt farey <ma...@gmail.com>.

alex@schnarff.com wrote:
>> Have you looked around for further config blocks of the type
>> <Directory /usr/local/www/data>
>> </Directory>
>> Does your server have rewrites in place for this, and is the file
>> listing you are seeing the location to which the DirectoryIndex
>> directive applies, it is the location directive in the vhosts section
>> that is making me think that theres more to the vhost setup for this
>> domain.
>>
>
> I have a few such blocks, but none are really relevant:
>
> <Directory />
>     AllowOverride None
>     Order Deny,Allow
>     Deny from all
> </Directory>
>
> <Directory "/usr/local/www">
> #
> # Possible values for the Options directive are "None", "All",
> # or any combination of:
> #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI
> MultiViews
> #
> # Note that "MultiViews" must be named *explicitly* --- "Options All"
> # doesn't give it to you.
> #
> # The Options directive is both complicated and important.  Please see
> # http://httpd.apache.org/docs-2.0/mod/core.html#options
> # for more information.
> #
>     Options Indexes FollowSymLinks +Includes
> #
> # AllowOverride controls what directives may be placed in .htaccess
> files.
> # It can be "All", "None", or any combination of the keywords:
> #   Options FileInfo AuthConfig Limit Indexes
> #
>     AllowOverride None
> #
> # Controls who can get stuff from this server.
> #
>     Order allow,deny
>     Allow from all
> </Directory>
>
> <Directory "/usr/local/www/icons">
>     Options Indexes MultiViews
>     AllowOverride None
>     Order allow,deny
>     Allow from all
> </Directory>
>
> <Directory "/usr/local/share/doc/apache2">
>     Options Indexes
>     AllowOverride None
>     Order allow,deny
>     Allow from all
>
>     <Files *.html>
>         SetHandler type-map
>     </Files>
>
>     SetEnvIf Request_URI ^/manual/(de|en|es|fr|ja|ko|ru)/
> prefer-language=$1
>     RedirectMatch 301 ^/manual(?:/(de|en|es|fr|ja|ko|ru)){2,}(/.*)?$
> /manual/$1$2
> </Directory>
>
> <Directory "/usr/local/www/cgi-bin">
>     AllowOverride None
>     Options None
>     Order allow,deny
>     Allow from all
> </Directory>
>
> There are no other "<Location /foo>" blocks, either. So unfortunately,
> that's probably not the cuase of the issue.
>
> Thanks,
> Alex
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
Interesting, Usually the things you define in the Vhost sections can
indeed be overridden in other places. Espcially "server wide" Aliases
that live in some other conf file.
Is it just one particular subdirectory that you have this issue with?
It could well be a particular module, does a bug search for this version
of apache/php come up with anything. I suppose you are stuck with this
and cant update? (I have had weird problems with mod_dav on many
occasions, but its only a wild guess) my advice would be temporarily
comment out modules not absolutely needed, and comment them in
gracefully restarting each time until the issue returns. Sorry to be
stumpled!

On one more unrelated point do you really want this:

      <Limit PUT POST DELETE PROPFIND PROPPATCH MKCOL COPY MOVE LOCK
UNLOCK>
        Require user peabody, gus
      </Limit>

which essentially says dont require valid user for GET and the others
not listed, I only mention it in case because it would be more easily
said like this:
| <LimitExcept GET>
|  Require user peabody, gus
| </LimitExcept>

to which you could add a smaller list of _allowed_ methods so I just
wondered if it was what was intended.

|If you want to require a valid user whatever the method then dont
bother with the limit statement.


-- 
Matthew Farey



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] DirectoryIndex Not Working w/PHP on 2.0.58

Posted by al...@schnarff.com.
> Have you looked around for further config blocks of the type
> <Directory /usr/local/www/data>
> </Directory>
> Does your server have rewrites in place for this, and is the file
> listing you are seeing the location to which the DirectoryIndex
> directive applies, it is the location directive in the vhosts section
> that is making me think that theres more to the vhost setup for this domain.
>

I have a few such blocks, but none are really relevant:

<Directory />
     AllowOverride None
     Order Deny,Allow
     Deny from all
</Directory>

<Directory "/usr/local/www">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs-2.0/mod/core.html#options
# for more information.
#
     Options Indexes FollowSymLinks +Includes
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit Indexes
#
     AllowOverride None
#
# Controls who can get stuff from this server.
#
     Order allow,deny
     Allow from all
</Directory>

<Directory "/usr/local/www/icons">
     Options Indexes MultiViews
     AllowOverride None
     Order allow,deny
     Allow from all
</Directory>

<Directory "/usr/local/share/doc/apache2">
     Options Indexes
     AllowOverride None
     Order allow,deny
     Allow from all

     <Files *.html>
         SetHandler type-map
     </Files>

     SetEnvIf Request_URI ^/manual/(de|en|es|fr|ja|ko|ru)/ prefer-language=$1
     RedirectMatch 301 ^/manual(?:/(de|en|es|fr|ja|ko|ru)){2,}(/.*)?$ 
/manual/$1$2
</Directory>

<Directory "/usr/local/www/cgi-bin">
     AllowOverride None
     Options None
     Order allow,deny
     Allow from all
</Directory>

There are no other "<Location /foo>" blocks, either. So unfortunately, 
that's probably not the cuase of the issue.

Thanks,
Alex


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] DirectoryIndex Not Working w/PHP on 2.0.58

Posted by matt farey <ma...@gmail.com>.

alex@schnarff.com wrote:
> I've got a FreeBSD 5.4-RELEASE box that I've just fallen into
> administering, with an existing Apache 2.0.58 install. One of my first
> tasks has been to get PHP4 installed, so that the site can support a
> blog and some other features.
>
> The PHP installation went smoothly, as I did it via FreeBSD's ports
> tree. Phpinfo() shows a healthy install, and the blog functions
> great...except for the fact that it relies on index.php being served
> up for a given directory, which is not working.
>
> Having run into this problem before, I went off and added "index.php"
> to the global DirectoryIndex, which now looks like:
>
> DirectoryIndex index.html index.html.var index.php
>
> When this didn't work (I'm still getting a directory listing instead
> of the output of index.php when I hit
> http://www.myserver.com/subdirectory/), I figured it might have
> something to do with the fact that the domain in question was being
> served out of a VirtualHost directive. So I went in and tweaked the
> DirectoryIndex value for the virtual host, so that it is now:
>
>     DirectoryIndex index.html index.html.var index.asp index.php
>
> (The index.asp piece is because this site was earlier migrated from an
> IIS box; those files are actually just pure HTML in this case.)
>
> Note that I've also got:
>
> AddType application/x-httpd-php .php
>
> in my global config, and PHP pages will parse properly when called
> directly.
>
> Even with all this done, I'm still getting directory listings instead
> of the output of index.php. At this point, I'm baffled. The only thing
> I can think of is that there's lots of modules loaded, and perhaps one
> of them is conflicting with another somehow.
>
> In any case, here are those modules, as well as the relevant
> VirtualHost config:
>
> LoadModule access_module libexec/apache2/mod_access.so
> LoadModule auth_module libexec/apache2/mod_auth.so
> LoadModule auth_anon_module libexec/apache2/mod_auth_anon.so
> LoadModule auth_dbm_module libexec/apache2/mod_auth_dbm.so
> #LoadModule auth_digest_module libexec/apache2/mod_auth_digest.so
> #LoadModule file_cache_module libexec/apache2/mod_file_cache.so
> LoadModule charset_lite_module libexec/apache2/mod_charset_lite.so
> #LoadModule cache_module libexec/apache2/mod_cache.so
> #LoadModule disk_cache_module libexec/apache2/mod_disk_cache.so
> LoadModule include_module libexec/apache2/mod_include.so
> LoadModule deflate_module libexec/apache2/mod_deflate.so
> LoadModule log_config_module libexec/apache2/mod_log_config.so
> LoadModule logio_module libexec/apache2/mod_logio.so
> LoadModule env_module libexec/apache2/mod_env.so
> LoadModule mime_magic_module libexec/apache2/mod_mime_magic.so
> LoadModule cern_meta_module libexec/apache2/mod_cern_meta.so
> LoadModule expires_module libexec/apache2/mod_expires.so
> LoadModule headers_module libexec/apache2/mod_headers.so
> LoadModule usertrack_module libexec/apache2/mod_usertrack.so
> LoadModule unique_id_module libexec/apache2/mod_unique_id.so
> LoadModule setenvif_module libexec/apache2/mod_setenvif.so
> LoadModule proxy_module libexec/apache2/mod_proxy.so
> LoadModule proxy_http_module libexec/apache2/mod_proxy_http.so
> <IfDefine SSL>
> LoadModule ssl_module libexec/apache2/mod_ssl.so
> </IfDefine>
> LoadModule autoindex_module libexec/apache2/mod_autoindex.so
> LoadModule mime_module libexec/apache2/mod_mime.so
> LoadModule dav_module libexec/apache2/mod_dav.so
> LoadModule status_module libexec/apache2/mod_status.so
> LoadModule asis_module libexec/apache2/mod_asis.so
> LoadModule info_module libexec/apache2/mod_info.so
> LoadModule cgi_module libexec/apache2/mod_cgi.so
> LoadModule dav_fs_module libexec/apache2/mod_dav_fs.so
> LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
> LoadModule negotiation_module libexec/apache2/mod_negotiation.so
> LoadModule imap_module libexec/apache2/mod_imap.so
> LoadModule actions_module libexec/apache2/mod_actions.so
> LoadModule speling_module libexec/apache2/mod_speling.so
> LoadModule userdir_module libexec/apache2/mod_userdir.so
> LoadModule alias_module libexec/apache2/mod_alias.so
> LoadModule rewrite_module libexec/apache2/mod_rewrite.so
> #LoadModule php4_module libexec/apache2/libphp4.so
> #LoadModule php5_module        libexec/apache2/libphp5.so
> LoadModule php4_module        libexec/apache2/libphp4.so
> LoadModule dir_module libexec/apache2/mod_dir.so
>
> ...
>
> <VirtualHost *:80>
>     ServerAdmin peabody@wayback.com
>     DocumentRoot /usr/local/www/data
>     ServerName webdav.marssociety.org
>     DirectoryIndex index.html index.html.var index.asp index.php
>     ErrorLog /var/log/webdav-error_log
>     CustomLog /var/log/webdav-access_log combined
>     <Location /mdrs>
>      AuthName "MDRS WebDav"
>      AuthType Basic
>      AuthUserFile /usr/local/etc/apache2/users
>       DAV On
>       AllowOverride None
>       Options None
>       <Limit PUT POST DELETE PROPFIND PROPPATCH MKCOL COPY MOVE LOCK
> UNLOCK>
>         Require user peabody, gus
>       </Limit>
>    </Location>
>
> # To take acre of attenpts at relay spamming? The domain
> # always seems to be fem.to. Or I could use SQUID in the pattern as well
>    RewriteEngine On
>    RewriteCond %{HTTP:VIA} fem\.to [NC]
>    RewriteRule ^.*$ - [F]
> </VirtualHost>
>
> Any help at all would be greatly appreciated.
>
> Alex Kirk
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Have you looked around for further config blocks of the type
<Directory /usr/local/www/data>
</Directory>
Does your server have rewrites in place for this, and is the file
listing you are seeing the location to which the DirectoryIndex
directive applies, it is the location directive in the vhosts section
that is making me think that theres more to the vhost setup for this domain.

-- 
Matthew Farey



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org