3

Background :So in an attempt to learn apache, Im following along with the exercises in the book "Apache: The definitive guide". As part of these exercises, we're incrementally building up the httpd.conf file.

Problem: my html is getting served as plaintext. The mime-type is plain\text even though the file extension is .html

I'd like to know what directive i must add for it to pick up the right extension Here's my conf file :

User webuser  
Group webgroup
ServerName my586
DocumentRoot /usr/www/APACHE3/site.first/htdocs
TransferLog logs/access_log
Listen 80

Additional Info to help diagnose the problem:

The exercise also mentions adding the following directive: TypesConfig conf/mime.types

But this gives the following error: Invalid command 'TypesConfig', perhaps misspelled or defined by a module not included in the server configuration this led me to the believe it had something to d with the mod_mime module, but i havent been able to make it work through that either

Update: Interestingly, I presumed, images\jpegs would be shown as plain text too, but it shows them fine, i.e. sets the correct mime type on them.

5
  • Is this apache1 or apache2?
    – Alex J
    Jun 2, 2009 at 7:12
  • this is apache2
    – user7420
    Jun 2, 2009 at 7:26
  • So I elimintaed the posibilit of this having anything to do with the mod_mime. I made the TypesConfig directive work by adding the following directive : #Include /etc/apache2/mods-enabled/*.load #Include /etc/apache2/mods-enabled/*.conf But the original problem of .html extensions displaying as plaintext still remains. From what I can gather, apache is supposed to behave this way by default (change mime-type based on extension)
    – user7420
    Jun 2, 2009 at 7:29
  • Lines starting with a "#" are ignored. The "#" signifies the start of a comment. If you added lines starting with that they won't do anything :)
    – Alex J
    Jun 2, 2009 at 7:53
  • oops, the #'s were not intended. (looks like i miss my c\c++ days of #includes)
    – user7420
    Jun 2, 2009 at 7:59

2 Answers 2

2
AddType image/gif .gif 

It seems that if you want TypesConfig to work, you will need to make sure you have mod_mime loaded.

0

On linux distributions, you have a file /etc/mime.types which contains mime type definitions. It is loaded with the command TypesConfig after the load of the mime module :

LoadModule mime_module /usr/lib/apache2/modules/mod_mime.so
<IfModule mod_mime.c>
TypesConfig /etc/mime.types
</IfModule>

Inside the IfModule, you can also add charset and language declarations.

You must log in to answer this question.