mod_mime_xattr 0.4

Copyright 2004-2007 Lennart Poettering <mzzvzrkngge (at) 0pointer (dot) net>


Copyright 2004-2007 Lennart Poettering

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


Tue Apr 17 2007:

Version 0.4 released, changes include: updated for Apache 2.2; for compatibility with older Apache versions please use mod_mime_xattr 0.3.

Mon Jan 23 2006:

Version 0.3 released; changes include: ported to Apache 2.0 - For Apache 1 use versions <= 0.2

Sun Mar 28 2004:

Version 0.2 released; changes include: look for both user.mime_type and user.mime-type for compliance with XDG

Wed Mar 24 2004:

Version 0.1 released


mod_mime_xattr is a module for the Apache HTTPD 2.2 which may be used to set a range of MIME properties of files served from a document tree with extended attributes (EAs) as supported by the underlying file system. The current version of mod_mime_xattr has support for Linux style EAs which are supported by Linux 2.4 with the ACL/EA patches applied and vanilla Linux 2.6. The following attributes may be used:

Current Status

Version 0.4 is stable and more or less feature complete.



Enable the module by adding a new LoadModule to the Apache configuration files:

LoadModule mime_xattr_module /usr/lib/apache2/modules/

When enabled in the Apache configuration files, mod_mime_xattr introduces two new directory dependent configuration directives:

A simple example:

<Directory /var/www>
    XAttrMimeType On
    XAttrHandler On

In case you want to enable support for extended attributes for the entire server, use something like this:

<Directory />
    XAttrMimeType On


You may get/set an extended attribute for a file with the Linux command line utilities getfattr/setfattr:

setfattr -n "user.mime_type" -v "text/html" foo.file

The file foo.file will be served as HTML now. For more information consult the concerning man pages.

If used with symbolic links, mod_mime_xattr will first check if an EA is set for the symlink itself, and second for the file the link points to. The user.charset EA is only used when the user.mime_type EA is set as well.

CGI and PHP scripts

You may use the user.apache_handler EA to mark a file as CGI script:

setfattr -n "user.apache_handler" -v "cgi-script" foo.html

This will force the execution of foo.html as CGI program, regardless of the name of the file which identifies it as an HTML file.

If you have PHP configured in your Apache web server you may mark a file as PHP script regardless of its name:

setfattr -n "user.mime_type" -v "application/x-httpd-php" bar.html

Think twice before enabling mod_mime_xattr for document trees you do not trust because a rogue user may mark his files as executable CGI or PHP scripts with the technique described above.


A current release of Apache 2.2 with apxs, the development headers and libraries installed. You need to install libattr and its development package.

A port to other EA APIs has not been done yet. It should be fairly easy to do, however. Feel free to send me patches!

mod_mime_xattr was developed and tested on Debian GNU/Linux "testing" from January 2006, it should work on most other Linux distributions since it uses GNU autoconf source code configuration.


As this package is made with the GNU autotools you should run ./configure inside the distribution directory for configuring the source tree. After that you should run make for compilation and make install (as root) for installation of mod_mime_xattr.


None so far


The newest release is always available from

The current release is 0.4

Get mod_mime_xattr's development sources from the Subversion repository (viewcvs):

svn checkout svn:// mod_mime_xattr

If you want to be notified whenever I release a new version of this software use the subscription feature of Freshmeat.

Lennart Poettering <mzzvzrkngge (at) 0pointer (dot) net>, April 2007
$Id: 34 2007-04-17 12:56:08Z lennart $