zoukankan      html  css  js  c++  java
  • Httpd服务入门知识-Httpd服务常见配置案例之设定默认字符集

              Httpd服务入门知识-Httpd服务常见配置案例之设定默认字符集

                                                    作者:尹正杰

    版权声明:原创作品,谢绝转载!否则将追究法律责任。

    一.查看生产环境中使用的字符集案例

    1>.查看腾讯设置的默认字符集

    2>.查看京东设置的默认字符集

    二.修改httpd默认的字符集

    1>.查看默认的httpd字符集

    [root@node101.yinzhengjie.org.cn ~]# egrep -v "^ *#|^$" /etc/httpd/conf/httpd.conf | grep AddDefaultCharset           #中文字符集:GBK, GB2312, GB18030,不过推荐使用默认的UTF-8
    AddDefaultCharset UTF-8
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# curl -I http://127.0.0.1/
    HTTP/1.1 200 OK
    Date: Sun, 08 Dec 2019 21:27:39 GMT
    Server: Apache/2.4.6 (CentOS)
    Last-Modified: Sat, 07 Dec 2019 01:31:15 GMT
    ETag: "25-599131e54e9d8"
    Accept-Ranges: bytes
    Content-Length: 37
    Content-Type: text/html; charset=UTF-8
    
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]#

    2>.修改默认的httpd字符集为GB2312

    [root@node101.yinzhengjie.org.cn ~]# curl -I http://127.0.0.1/
    HTTP/1.1 200 OK
    Date: Sun, 08 Dec 2019 21:27:39 GMT
    Server: Apache/2.4.6 (CentOS)
    Last-Modified: Sat, 07 Dec 2019 01:31:15 GMT
    ETag: "25-599131e54e9d8"
    Accept-Ranges: bytes
    Content-Length: 37
    Content-Type: text/html; charset=UTF-8
    
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# egrep -v "^ *#|^$" /etc/httpd/conf/httpd.conf | grep AddDefaultCharset
    AddDefaultCharset UTF-8
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# cat /etc/httpd/conf.d/charset.conf
    AddDefaultCharset GB2312
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# egrep -v "^ *#|^$" /etc/httpd/conf/httpd.conf  | grep ServerRoot
    ServerRoot "/etc/httpd"
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# egrep -v "^ *#|^$" /etc/httpd/conf/httpd.conf  | grep IncludeOptional
    IncludeOptional conf.d/*.conf
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# egrep -v "^ *#|^$" /etc/httpd/conf/httpd.conf | grep AddDefaultCharset
    AddDefaultCharset UTF-8
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# cat /etc/httpd/conf.d/charset.conf        #尽管主配置文件默认定义的是UTF8,但咱们在子配置文件中显式定义的编码依旧是优先生效的~
    AddDefaultCharset GB2312
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# httpd -t
    Syntax OK
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# systemctl restart httpd
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# curl -I http://127.0.0.1/
    HTTP/1.1 200 OK
    Date: Sun, 08 Dec 2019 21:32:00 GMT
    Server: Apache/2.4.6 (CentOS)
    Last-Modified: Sat, 07 Dec 2019 01:31:15 GMT
    ETag: "25-599131e54e9d8"
    Accept-Ranges: bytes
    Content-Length: 37
    Content-Type: text/html; charset=GB2312
    
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# 
  • 相关阅读:
    对象和数据绑定的问题
    Qt父窗口设置为桌面
    MIS的趋势必定是围绕机器取代人手,分工越来越细(小餐厅都支持微信自助点餐,结账时就打个折,相当于省了1、2个人手,SQL发明以后,程序员的工作更多了)
    使用开源软件做项目有风险
    开源免费的C/C++网络库(c/c++ sockets library)
    Bash
    sass
    Spire.XLS
    NET Core+Code First+Docker
    实战网络性能优化
  • 原文地址:https://www.cnblogs.com/yinzhengjie/p/12004555.html
Copyright © 2011-2022 走看看