How to let Nginx support Chinese filename specific setup steps _nginx

Source: Internet
Author: User
Tags locale
First you have to let your system have a Chinese language pack:

Setup can be performed before: locale look, if the display is en_US. UTF-8, which is normal, does not have to follow the steps set below. If you want to display additional encodings, you need to set the following steps.

Centos

Edit/etc/sysconfig/i18n file, modify the contents to: (Can use VI, nano or WINSCP graphics management software, according to individual taste choice)

Lang= "en_US. UTF-8 "

Sysfont= "Latarcyrheb-sun16"

Save and reboot the system.

Debian

Apt-get install-y locales

Dpkg-reconfigure locales

The following dialog box appears when you perform dpkg-reconfigure locales:

Use the DOWN ARROW keys to find en_US. UTF-8 UTF-8, press the space to select, and then press ENTER.

Then press the DOWN ARROW key to select en_US. UTF-8, then press ENTER to confirm, reboot the system.

Ubuntu

Edit the/etc/default/locale file and modify the content to (create one without words):

Lang= "en_US. UTF-8 "

Language= "En_us:en"

Save, then execute:

Locale-gen en_US en_US. UTF-8

Reboot the system.

Execution: Locale to see if the display is en_US. UTF-8, if the error, please feedback in this article. The above steps are set up to support Chinese, you can upload Chinese documents or Chinese directories.

The character set configured in the Nginx.conf file is also utf-8

server {

Listen 80;

server_name test.cn;

Root/data;

Index index.html index.jsp;

CharSet Utf-8;

......

AY%PM ' g+u0

The client uses is SECURECRT, uses the character set to Utf-8, uses the uft-8 later to use the RZ to upload the file, in IE the Chinese may display normally.

Attention:

If the Chinese filename is gb2312 needs to be converted into utf-8. (Note is the filename, not the contents of the file). Use CONVMV conversion (if this command is not found, this package convmv-1.10-1.el5.noarch.rpm in the disc) Convmv-fgbk-tutf8-r--notesttarget

Where-f is the source code,-T is the target encoding,-R is a recursive directory, –notest is not moving, actually renaming the file (actually do rename the files), target is the destination directory. The rest of the parameters can refer to man or-H.

If you do not change the code before uploading the file, set good will still be garbled, it is recommended to upload the file again. If no backup of the original file can be converted using the following command: For f in ' LS *.html '; Do mv $f ' ls $f |iconv-f gbk-t UTF-8 '; Done.

Where *.html is the type of file to be converted, it can also be replaced by *.txt,*.rar is mainly to see what file you are, inside the GBK for the source file encoding type, if you do not know the source file encoding type can be executed: File-bi file name.

If you want to change under Windows, it's also possible. EditPlus has the ability to modify the file code, other software may also have such functions, you can study it.

If it is a directory, there seems to be no way to convert it now.

There is also a problem, if it is HTML, such as Web page files, if the original page content is gb2312 or similar to the Utf-8 encoding, first of all, the page inside the charset to Charset=utf-8, and then convert file encoding, otherwise the page will be garbled.

CONVMV can be downloaded from HTTP://J3E.DE/LINUX/CONVMV,

wget http://j3e.de/linux/convmv/convmv-1.14.tar.gz

TAR-ZXVF convmv-1.14.tar.gz

CD convmv-1.14

Make clean;

make install;

Such as:

./convmv-f gb2312-t UTF-8-R--nosmart--notest userfiles/*.*

The file name above indicates that all files under Userfiles are converted to UTF-8 by GB2312

You can use Iconv for character set translation of file content

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.