VPS侦探论坛

 找回密码
 注册
查看: 8881|回复: 4

lnmp1.2版本安装GBK版本的discuz X3.2乱码

[复制链接]
发表于 2016-3-3 15:30:46 | 显示全部楼层 |阅读模式

PHP版本:PHP 5.6.9 (cli) (built: Mar  1 2016 12:06:49)
MySQL版本:mysql  Ver 14.14 Distrib 5.5.42, for Linux (x86_64) using readline 5.1
nginx版本:nginx version: nginx/1.8.0
discuz版本:简体中文GBK(Discuz_X3.2_SC_GBK.zip)
OS:CentOS release 6.5 (Final)

程序上传方式:
wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_GBK.zip
unzip Discuz_X3.2_SC_GBK.zip

浏览器:IE11(自动编码)、Chrome 50.0.2652.2、firefox 42,全部都是自动编码,默认UTF8
浏览器均没有判断正确。

通过抓包发现是因为在response header里面通通返回了content-type:UTF-8

nginx配置文件:
  1. user  www www;

  2. worker_processes auto;

  3. error_log  /home/wwwlogs/nginx_error.log  crit;

  4. pid        /usr/local/nginx/logs/nginx.pid;

  5. #Specifies the value for maximum file descriptors that can be opened by this process.
  6. worker_rlimit_nofile 51200;

  7. events
  8.     {
  9.         use epoll;
  10.         worker_connections 51200;
  11.         multi_accept on;
  12.     }

  13. http
  14.     {
  15.         include       mime.types;
  16.         default_type  application/octet-stream;

  17.         server_names_hash_bucket_size 128;
  18.         client_header_buffer_size 32k;
  19.         large_client_header_buffers 4 32k;
  20.         client_max_body_size 50m;

  21.         sendfile   on;
  22.         tcp_nopush on;

  23.         keepalive_timeout 60;

  24.         tcp_nodelay on;

  25.         fastcgi_connect_timeout 300;
  26.         fastcgi_send_timeout 300;
  27.         fastcgi_read_timeout 300;
  28.         fastcgi_buffer_size 64k;
  29.         fastcgi_buffers 4 64k;
  30.         fastcgi_busy_buffers_size 128k;
  31.         fastcgi_temp_file_write_size 256k;

  32.         gzip on;
  33.         gzip_min_length  1k;
  34.         gzip_buffers     4 16k;
  35.         gzip_http_version 1.1;
  36.         gzip_comp_level 2;
  37.         gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
  38.         gzip_vary on;
  39.         gzip_proxied   expired no-cache no-store private auth;
  40.         gzip_disable   "MSIE [1-6]\.";

  41.         #limit_conn_zone $binary_remote_addr zone=perip:10m;
  42.         ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.

  43.         server_tokens off;
  44.         #log format
  45.         log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
  46.              '$status $body_bytes_sent "$http_referer" '
  47.              '"$http_user_agent" $http_x_forwarded_for';
  48.                 access_log off;

  49. server
  50.     {
  51.         listen 80 default_server;
  52.         #listen [::]:80 default_server ipv6only=on;
  53.         server_name www.lnmp.org;
  54.         index index.html index.htm index.php;
  55.         root  /home/wwwroot/default;

  56.         charset gbk;
  57.         
  58.         #error_page   404   /404.html;
  59.         include enable-php.conf;

  60.         location /nginx_status
  61.         {
  62.             stub_status on;
  63.             access_log   off;
  64.         }

  65.         location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  66.         {
  67.             expires      30d;
  68.         }

  69.         location ~ .*\.(js|css)?$
  70.         {
  71.             expires      12h;
  72.         }

  73.         location ~ /\.
  74.         {
  75.             deny all;
  76.         }

  77.         access_log  /home/wwwlogs/access.log  access;
  78.     }
  79. include vhost/*.conf;
  80. }
复制代码
即使设置了GBK字符集(也试过了设置gb2312字符集),在response header里面通通返回content_type:utf-8
修改过conf文件之后,均重启过nginx+重启过系统,但毫无作用

除了nginx的配置文件外,其他全部都是lnmp1.2的默认配置,没有做过任何修改。

难道lnmp不支持gbk程序?

[ 本帖最后由 work4seo 于 2016-3-3 15:41 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2016-3-3 20:52:16 | 显示全部楼层


直接charset gbk; 就行,我这边测试也没有问题
[root@vpser ~]# curl -IL 69.163.35.abc
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 03 Mar 2016 10:51:06 GMT
Content-Type: text/html; charset=gbk
Content-Length: 2502
Last-Modified: Wed, 02 Mar 2016 02:18:16 GMT
Connection: keep-alive
Vary: Accept-Encoding
ETag: "56d64d68-9c6"
Accept-Ranges: bytes

你建站是建站默认虚拟主机目录吗?
如果不是建在默认虚拟主机目录,你改默认虚拟主机的配置是不影响其他虚拟主机的
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2016-3-7 11:25:54 | 显示全部楼层

回复 2# 的帖子


我已经快崩溃了,已经好几天了,这个诡异的问题还是没有搞定
默认目录(未添加虚拟主机的情况下)
周日的时候试着添加了虚拟主机,在虚拟主机目录下,修改了vhost目录下对应的配置文件
通通都是乱码。
因为数据库的问题,限定了只能用GBK的DZ版本
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2016-3-7 13:27:46 | 显示全部楼层



没关系,,,也就在你安装的时候会显示乱码,   你自己手动改一下为gbk编码安装就成了,   
安装后就正常显示的.  因为安装php页面没有做强制编码,   安装后论坛配制里是强制GBK编码的..      
这个不影响你论坛的正常运行.

如果实在纠结这个,,,那你就强制把php.ini 里的默认编码改为  bgk就成了

sed -i 's/default_charset = \"UTF-8\"/default_charset = \"gbk\"/g' /usr/local/php/etc/php.ini
/etc/init.d/php-fpm restart

如果你的程序都是GBK程序还好,,要是还有Utf-8程序,,那也会出现乱码,编码不能正常识别.
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2019-2-2 22:47:52 | 显示全部楼层

我跟楼主一样问题,解决办法是:修改/usr/local/php/etc/php.ini文件 default_charset = ""
我们这里也不要写GBK编码,你写了后这台服务器如果安装UTF-8编码程序有又有问题,所以我们都不写,让自动默认。

军哥运维代购:http://shop63846532.taobao.com/

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-5-4 04:45 , Processed in 0.027275 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表