How to change apache2 default charset in Ubuntu

If you want to change the apache2 default charset in Ubuntu try this procedure

You need to edit this file /etc/apache2/conf.d/charset

sudo gedit /etc/apache2/conf.d/charset

next you should change the line

#AddDefaultCharset ISO-8859-1

to

AddDefaultCharset {YOUR_DEFAULT_CHARSET | Example: UTF-8}

save and exit the file

Now you need to restart the apache server using the following command

sudo /etc/init.d/apache2 restart

Sponsored Link

You may also like...

3 Responses

  1. Anders says:

    Thanks! 🙂 I have been struggling with this for a time.

  2. Martijn says:

    Be careful with this one since it can bite you.
    According to the Apache manual:

    AddDefaultCharset should only be used when all of the text resources to which it applies are known to be in that character encoding and it is too inconvenient to label their charset individually.

    It even overrides the content-type meta tags in the body of a page. I don’t think this makes sense, but that’s how it works.

  3. rajkumar says:

    i have done the same thing but the changes are not applied.

Leave a Reply

Your email address will not be published. Required fields are marked *