Today, when I deployed a small web project on Nginx, Chinese appeared garbled, searched, online solution is the same, change the server coding format.

Here’s a summary of the solution: Garbled characters may occur because encoding formats are not configured for the following two positions:

1. Set the utF-8 encoding format for the web page code as follows:

<! DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; Charset =utf-8" /> <title>中文 title> </head> <body> <center>Copy the code

2, nginx server, nginx.conf set utF-8 encoding format: note that the server layer and access path location must be configured

server { listen 81; Set $root: F/Develop/nginx 1.14.0 / HTML; root $root; server_name localhost; access_log logs/host.access.log main; index index.html index.php; Charset UTF-8; location / { root html; index index.html index.htm; charset utf-8; }}Copy the code

Nginx -s reload nginx -s reload

Final access test: Chinese parsing normal.