How to Fix LC_CTYPE setlocale Error in Centos/Redhat 6 / 7

During remote access into Linux Centos/Redhat, it’s common to see setlocale error if using UTF-8 encoding; especially using terminal program like iterm / iterm2. This is due to iterm terminal allow to set the UTF-8 encoding environment.

This is the error you will see when SSH into the server; compiling perl; compiling python and etc.

To fix the error in Linux Centos/Redhat 6, follow the step below;

  1. Edit the file /etc/sysconfig/i18n, add this line into the file

2. In the file it should look like this.

To fix the error in Linux Centos/Redhat 7, follow the step below;

  1. Edit the file /etc/locale.conf, add this line into the file

2. In the file, it should look like this

That will fix the annoy error when compiling on Python/Perl.