Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The solution of Chinese garbled Code in nginx php

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 291

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report