1、网页代码设置utf-8编码格式,如下。

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>中文标题</title>
</head>
<body>
<center>测试中文</center>
</body>
</html>

2、nginx服务端,nginx.conf设置utf-8编码格式:注意server层 和 访问路径location都要配置一下,如下

    server {
    listen 81;
    root /opt/local; 
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;
    }
}

修改了nginx的配置文件,重新加载一下nginx,我这边linux服务器安装的nginx的地址为/opt/local/nginx。重启加载命令如下

/opt/local/nginx/skbn/nginx -s reload
最后修改:2021 年 07 月 21 日
如果觉得我的文章对你有用,请随意赞赏