Linux站群服务器Debian系统常见问题及解决方法
服务器环境:Debian 12系统,网站运行环境为 Nginx 1.28 + PHP 8.2 + Mysql 8.0 + 宝塔 V 11.7
问题一:SSH执行命令时,经常有错误提示cannot change locale (en_US.UTF-8)
通过SSH连接服务器时,操作命令经常提示错误,错误提示信息:
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

一键修复方案,推荐直接执行
apt update apt install -y locales sed -i 's/^# *en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen sed -i 's/^# *zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/' /etc/locale.gen locale-gen update-locale LANG=en_US.UTF-8 LC_ALL=
使用上面命令执行完成后,就可以解决 warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8) 报错的问题;
问题二:重启Nginx时有错误提示
使用命令 /etc/init.d/nginx restart 重启Nginx服务的时候有错误提示,错误提示如下:
root@S202512097449:/www/wwwlogs/free_waf_log# /etc/init.d/nginx restart
Stoping nginx... nginx: [warn] could not build optimal server_names_hash, you should increase either server_names_hash_max_size: 512 or server_names_hash_bucket_size: 512; ignoring server_names_hash_bucket_size
nginx: [warn] could not build optimal server_names_hash, you should increase either server_names_hash_max_size: 512 or server_names_hash_bucket_size: 512; ignoring server_names_hash_bucket_size
done
Starting nginx... nginx (pid 1868437 1868436 1868435 1868434 1868433 1868432 1868431 1868430 1868429 1868428 1868427 1868426 1868425 1868424 1868423 1868422 1868421 1868420 1868419 1868418 1868417 1868416 1868415 1868414 1868413 1868412 1868411 1868410 1868409 1868408 1868407 1868406 1868405 1868404 1868403 1868402 1868401 1868400 1868399 1868398 1868397) already running.

解决方法
进入宝塔面板,点击 Nginx —— 配置文件,修改位置
在 http { ... } 里面,找到这里:
server_names_hash_bucket_size 512; client_header_buffer_size 32k;
改成:
server_names_hash_bucket_size 512; server_names_hash_max_size 8192; client_header_buffer_size 32k;

修改完Nginx配置文件之后,先保存,然后重启一下Nginx就可以解决这个问题;
问题三 SSH连接服务器时提示错误 KiTTY Fatal Error
报错信息:
KiTTY Fatal Error
Remote side unexpectedly closed network connection
报错信息2:
Network error: Connection reset by peer

解决办法
这个问题多数是服务器供应商机房的安全规则限制,可以和服务商沟通,部分服务器商只开通服务器的部分端口访问,限制了大部分端口的访问权限,主要是为了提升服务器的安全性;
我更换了服务器的ssh连接端口,现在可以正常连接了;


评论