Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ubuntu/Lighttpd is not serving my UTF-8 encoded files with the correct Content-Type header. It's sending Content-Type: text/html rather than Content-Type: text/html; charset=UTF-8. How do I configure Lighttpd to send the correct headers?

I didn't see any useful settings in the default lighttpd.conf and am having trouble finding information in the documentation.

share|improve this question

migrated from Aug 22 '11 at 6:47

This question came from our site for professional and enthusiast programmers.

up vote 7 down vote accepted

The default lighttpd.conf file seems to load MIME types from /etc/mime.types using a perl script:

include_shell "/usr/share/lighttpd/"

In my /etc/mime.types my html files had been set to be served as text/html. I commented out the include_shell perl script and added the following mimetype.assign entry to lighttpd.conf:

mimetype.assign = ( ".html" => "text/html; charset=utf-8" )

I'm not sure if there's a more elegant solution. Using this method I would need to copy in all of the entries in /etc/mime.types to retain the other MIME type mappings.

share|improve this answer

I was having the very same problem and finally found a solution on a blog

Basically it's a pimped version of above mentioned perl script that adds the charset=utf-8 declaration to all mime-types that start with "text/" Just replace the perl script and restart lighttpd.

share|improve this answer
This solution is more elegant, the Michael Dudley solution is not satisfying as its either copying statically all the content or lacking mimetypes for all non-html data … – Jocelyn delalande Mar 13 '13 at 9:23

It isn't cleaner to just add the `; charset=utf-8 string´ for each "text/" line in mimes.conf? I mean like:

  ".css"          =>      "text/css; charset=utf-8",
  ".html"         =>      "text/html; charset=utf-8",
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.