The solution of Chinese garbled Code in nginx php
This article mainly introduces the solution of nginx php Chinese garbled code, the article is very detailed, has a certain reference value, interested friends must read it!
Nginx php Chinese garbled solutions: 1, the web page code to set utf-8 coding format; 2, in the nginx server and nginx.conf to set utf-8 coding format.
This article operating environment: linux5.9.8 system, nginx1.14.0 version, Dell G3 computer
Solution of Chinese garbled code in nginx access page
When deploying a small web page project on nginx, there are garbled codes in Chinese. After searching it, the online solutions are all the same.
Change the coding format of the server.
Here's a summary of the solution: garbled may be due to no coding format configured in the following two locations:
1. The web page code is formatted in utf-8, as follows.
Chinese title Wechat search: snail linux
2. On the nginx server, nginx.conf sets the utf-8 encoding format: note that both the server layer and the access path location should be configured.
Server {listen 81; set $root Flav hand developer nginxl.14.0 root; server_name localhost; access_log logs/host.access.log main; index index.html index.php;; set the character set charset utf-8; location / {root html; index index.html index.htm; charset utf-8 }}
Modified the configuration file of nginx to reload nginx
Nginx-s reload
Finally, the access test showed that the Chinese parsing was normal.
The above is all the contents of this article entitled "the solution to Chinese garbled codes in nginx php". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!