Explain the configuration process of making Nginx server support Chinese url in Linux environment

  • 2020-05-12 06:47:24
  • OfStack

1: make sure your system is UTF


[root@Tserver ~]# env|grep LANG
LANG=en_US.UTF-8

2: the default encoding in the NGINX configuration file is set to utf-8


server
{
listen 80;
server_name .inginx.com ;
index index.html index.htm index.php;
root /usr/local/nginx/html/inginx.com;
charset utf-8;
}


If you are using securecrt to upload a file, please select the return message > Appearance of � UTF - 8
FTP also sets the default encoding to TUF-8

3. Convert the non-UTF-8 file name to UTF-8
The advantage of using nginx is that it can use Chinese url, but the Chinese code of the file name of Windows is GBK by default, which needs to be converted
It is very simple to change the file name to utf8 code! (but apache doesn't have to be that bothered.)
Install convmv and let him convert the code:


yum install convmv -y
convmv -f GBK -t UTF8 -r --notest target  The target path 

Where -f is the source code, -t is the target code, -r is the recursively processed directory, -notest is not moving, actually renaming the file, and target is the target directory
For the windows operating system, this method can be ignored. When using nginx forwarding under windows 1, this kind of problem will not occur. The first method only applies to the operation under linux.


Related articles: