MXBLOG - baota
type: channel
link: https://moonjer.com/category/baota/
items: 解决Docker容器中MySQL连接因LANG环境变量缺失导致的问题
items: Docker一键部署宝塔面板教程
items: nginx宝塔面板下的配置
items: 宝塔面板启动项配置
items: centos宝塔面板安装命令
items: 宝塔面板安装脚本
items: 群晖开机启动docker宝塔和nginx
items: ubuntu宝塔面板安装nginx-rtmp-module
items: Nginx配置tcp请求端口转发
items: docker运行宝塔面板

解决Docker容器中MySQL连接因LANG环境变量缺失导致的问题
type: item
date: 2025-08-27T15:29:00+08:00
description: 解决Docker容器中MySQL连接因LANG环境变量缺失导致的问题问题描述在使用Docker容器部署Spring Boot应用时，遇到以下错误：java.lang.IllegalStateException: DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect环境信息：Docker容器：基于Ubuntu 22.04，运行宝塔面板数据库：MySQL 8.0.26（独立容器）应用：Spring Boot + Logback + MySQL Connector 8.0.16关键发现：同样的JAR包在虚拟机上运行正常，在容器中无法启动快速解决方案根本解决方案（推荐）：apt-get update && apt-get install -y locales && locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8 && export LANG=en_US.UTF-8 && export LC_ALL=en_US.UTF-8 && echo 'export LANG=en_US.UTF-8' >> ~/.bashrc && echo 'export LC_ALL=en_US.UTF-8' >> ~/.bashrc && source ~/.bashrc临时解决方案（连接参数）：在数据库连接URL中添加：allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8spring: datasource: url: jdbc:mysql://127.0.0.1:3306/your_database?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8或者在启动容器时添加环境变量：docker run -d \ --name your-container \ --net=host \ --restart always \ --privileged \ -e LANG=C.UTF-8 \ -e LC_ALL=C.UTF-8 \ your-image:tag详细排查过程初期错误理解最初看到错误信息，以为是Logback配置问题，尝试了多种方案：取消注释SQL方言配置 ❌<sqlDialect class="ch.qos.logback.core.db.dialect.MySQLDialect"/>使用DriverManagerConnectionSource ❌升级/降级Logback版本 ❌使用HikariCP替代Commons DBCP ❌暂时禁用DBAppender ✅（临时方案，不是根本解决）转换思路：环境差异分析经过两天的配置调试无果后，开始从环境角度分析问题。1. Java版本对比# 容器和虚拟机都是相同版本 java version "1.8.0_381" Java(TM) SE Runtime Environment (build 1.8.0_381-b09)2. 环境变量对比容器环境：JAVA_HOME=/home/root/soft/jdk1.8.0_381 PATH=/home/root/soft/jdk1.8.0_381/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin # 缺失 LANG 和 LC_* 变量虚拟机环境：JAVA_HOME=/home/root/soft/jdk1.8.0_381 LANG=en_US.UTF-8 # 关键差异！ PATH=/home/root/soft/jdk1.8.0_381/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin3. MySQL驱动行为测试创建测试程序验证MySQL驱动的getGeneratedKeys支持：import java.sql.*; public class TestMySQLDriver { public static void main(String[] args) { try { Class.forName("com.…

Docker一键部署宝塔面板教程
type: item
date: 2024-09-05T00:12:01+08:00
description: 一、镜像特点全程自动安装依赖自动安装宝塔面板、环境、插件自动修改默认面板端口、用户名、密码、安全入口自动配置镜像SSH自动同意首次登陆的用户协议自动取消强制登录自动降级为7.7.0版本修复面板XSS高危漏洞兼容新版本面板运行环境去除专业/企业应用安装权限去除宝塔面板强制绑定账号去除各种删除操作时的计算题与延时等待去除创建网站自动创建的垃圾文件（index.html、404.html、.htaccess）关闭未绑定域名提示页面，防止有人访问未绑定域名直接看出来是用的宝塔面板关闭活动推荐与在线客服，去除首页企业版广告去除自动校验文件与上报信息定时任务去除面板日志与网站绑定域名上报二、版本来源优化版：latest --> https://github.com/gettionhub/baota专业版：pro --> https://bt.sy/bbs/thread-2-1-1.html企业版：ltd --> https://bt.sy/bbs/thread-3-1-1.html建议使用 latest 版本镜像，手动分离数据库外置，比如搭配adminer+mariadb+postgres的docker镜像，将宝塔面板容器和数据库容器连接使用，以防止意外发生导致数据库丢失或泄露。三、如何部署面板默认信息登录地址：http://{{面板ip地址}}:8888/baota用户名：baotao密码：baota端口：8888安全入口：/baotaSSH端口：22SSH root用户密码：baota注意：部署后务必先修改如上信息，以防被利用！部署方式1. 通过 docker run 运行docker run -itd \ --name baota \ --network=host \ --privileged=true \ --restart=unless-stopped \ -v ~/www/wwwroot:/www/wwwroot \ -v ~/www/vhost:/www/server/panel/vhost \ gettionhub/baota:latest2. 通过 docker-compose 运行git clone https://github.com/gettionhub/baota.git cd baota docker pull gettionhub/baota:latest COMPOSE_HTTP_TIMEOUT=1200 docker-compose --verbose up -d3. 通过 docker-compose 配置version: '3.3' services: baota: image: gettionhub/baota:latest #优化版 #image: gettionhub/baota:pro #专业版 #image: gettionhub/baota:ltd #企业版 container_name: baota #容器名 network_mode: bridge #网络模式 privileged: true #root权限 restart: unless-stopped ports: - 8880:80 - 8443:443 - 8888:8888 - 888:888 volumes: - ./web:/www/wwwroot #网站数据目录 - ./data:/www/server/data #MySQL数据目录 - ./vhost:/www/server/panel/vhost #vhost文件路径四、常用命令获取宝塔面板默认信息docker exec -it baota /etc/init.d/bt default重启nginxdocker exec -it baota /etc/init.d/nginx restart重启PHPdocker exec -it baota /etc/init.d/php-fpm-80 restart重启mysqldocker exec -it baota /etc/init.d/mysqld restart进入宝塔容器docker exec -it baota /bin/sh五、破解教程（仅供学习交流）请注意，任何破解行为都可能违反软件许可协议，并且存在法律风险，因此下面提供的教程仅供技术学习和交流，不建议在实际环境中使用。1. 解除面板时间限制使用文件管理器进入 /www/server/panel/data/ 目录，找到 plugin.json 文件。编辑 plugin.json 文件。使用编辑器查找 "endtime": -1 并将其替换为 "endtime": 999999999999。保存更改。2. 解除面板版本授权继续在 plugin.json 文件…

nginx宝塔面板下的配置
type: item
date: 2023-03-16T17:29:00+08:00
description: 一、nginx.conf配置fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 256k; fastcgi_intercept_errors on; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml; gzip_vary on; gzip_proxied expired no-cache no-store private auth; gzip_disable "MSIE [1-6]\.";二、编译配置./configure宝塔面板所有编译配置./configure \ --user=www \ --group=www \ --prefix=/www/server/nginx \ --add-module=srclib/ngx_devel_kit \ --add-module=srclib/lua_nginx_module \ --add-module=srclib/ngx_cache_purge \ --add-module=srclib/nginx-sticky-module \ --with-openssl=srclib/openssl \ --with-pcre=srclib/pcre-8.43 \ --with-http_v2_module \ --with-stream \ --with-stream_ssl_module \ --with-stream_ssl_preread_module \ --with-http_stub_status_module \ --with-http_ssl_module \ --with-http_image_filter_module \ --with-http_gzip_static_module \ --with-http_gunzip_module \ --with-ipv6 \ --with-http_sub_module \ --with-http_flv_module \ --with-http_addition_module \ --with-http_realip_module \ --with-http_mp4_module \ --with-ld-opt=-Wl,-E \ --with-cc-opt=-Wno-error \ --with-http_dav_module \ --add-module=srclib/nginx-dav-ext-module普通安装下需要的常用编译配置./configure \ --with-http_v2_module \ --with-stream \ --with-stream_ssl_module \ --with-stream_ssl_preread_module \ --with-http_stub_status_module \ --with-http_ssl_module \ --with-http_gzip_static_module \ --with-http_gunzip_module \ --with-http_sub_module \ --with-http_flv_module \ --with-http_addition_module \ --with-http_realip_module \ --with-http_mp4_module \ --with-ld-opt=-Wl,-E \ --with-cc-opt=-Wno-error \ --with-http_dav_module三、server配置server { listen 80; listen 443 ssl http2; server_name www.starguar.com; index index.php index.html index.htm default.php default.htm default.html; root /home/ecs-user/…

宝塔面板启动项配置
type: item
date: 2022-12-20T17:32:00+08:00
description: #!/bin/bash # chkconfig: 2345 55 25 # description: bt Cloud Service ### BEGIN INIT INFO # Provides: bt # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts bt # Description: starts the bt ### END INIT INFO panel_init(){ panel_path=/www/server/panel pidfile=$panel_path/logs/panel.pid cd $panel_path env_path=$panel_path/pyenv/bin/activate if [ -f $env_path ];then source $env_path pythonV=$panel_path/pyenv/bin/python chmod -R 700 $panel_path/pyenv/bin else pythonV=/usr/bin/python fi reg="^#\!$pythonV\$" is_sed=$(cat $panel_path/BT-Panel|head -n 1|grep -E $reg) if [ "${is_sed}" = "" ];then sed -i "s@^#!.*@#!$pythonV@" $panel_path/BT-Panel fi is_sed=$(cat $panel_path/BT-Task|head -n 1|grep -E $reg) if [ "${is_sed}" = "" ];then sed -i "s@^#!.*@#!$pythonV@" $panel_path/BT-Task fi chmod 700 $panel_path/BT-Panel chmod 700 $panel_path/BT-Task log_file=$panel_path/logs/error.log task_log_file=$panel_path/logs/task.log if [ -f $panel_path/data/ssl.pl ];then log_file=/dev/null fi port=$(cat $panel_path/data/port.pl) } panel_init get_panel_pids(){ isStart=$(ps aux|grep -E '(runserver|BT-Panel)'|grep -v grep|awk '{print $2}'|xargs) pids=$isStart arr=$isStart } get_task_pids(){ isStart=$(ps aux|grep -E '(task.py|BT-Task)'|grep -v grep|awk '{print $2}'|xargs) pids=$isStart arr=$isStart } panel_start() { isStart=`ps aux|grep 'runserver:app'|grep -v grep|awk '{print $2}'` if [ "$isStart" != '' ];then kill -9 $isStart fi get_panel_pids if [ "$isStart" == '' ];then rm -f $pidfile panel_port_check echo -e "Starting Bt-Panel...\c" nohup $panel_path/BT-Panel >> $log_file 2>&1 & isStart="" n=0 while "$isStart" == "" ; do echo -e ".\c" sleep 0.5 get_panel_pids let n+=1 if [ $n -gt 8 ];then break; fi done if [ "$isStart" == '' ];then echo -e "\033[31mfailed\033[0m" echo '------------------------------------------------------' tail -n 20 $log_file echo '------------------------------------------------------' echo -e "\033[…

centos宝塔面板安装命令
type: item
date: 2022-11-30T22:05:00+08:00
description: #!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH echo " +---------------------------------------------------------------------- | Bt-WebPanel 3.0 FOR CentOS beta +---------------------------------------------------------------------- | Copyright (c) 2015-2017 BT-SOFT(http://www.bt.cn) All rights reserved. +---------------------------------------------------------------------- | Python2.6/2.7 successful the http://SERVER_IP:8888 is WebPanel +---------------------------------------------------------------------- " download_Url='http://download.bt.cn' setup_patn=/www while [ "$go" != 'y' ] && [ "$go" != 'n' ] do read -p "Now do you want to install Bt-Panel to the $setup_patn directory?(y/n): " go; done if [ "$go" == 'n' ];then exit; fi yum -y install ntp \cp -a -r /usr/share/zoneinfo/Asia/Shanghai /etc/localtime echo 'Synchronizing system time..' ntpdate 0.asia.pool.ntp.org hwclock -w startTime=`date +%s` rm -f /var/run/yum.pid paces="wget python-devel python-imaging zip unzip openssl openssl-devel gcc libxml2 libxml2-dev libxslt* zlib zlib-devel libjpeg-devel libpng-devel libwebp libwebp-devel freetype freetype-devel lsof pcre pcre-devel vixie-cron crontabs" yum -y install $paces if [ ! -f '/usr/bin/mysql_config' ];then yum install mysql-devel -y fi tmp=`python -V 2>&1|awk '{print $2}'` pVersion=${tmp:0:3} if [ ! -f "/usr/lib/python${pVersion}/site-packages/setuptools-33.1.1-py${pVersion}.egg" ];then wget $download_Url/install/src/setuptools-33.1.1.zip -T 10 unzip setuptools-33.1.1.zip rm -f setuptools-33.1.1.zip cd setuptools-33.1.1 python setup.py install cd .. rm -rf setuptools-33.1.1 fi if [ ! -f "/usr/lib64/python${pVersion}/site-packages/Pillow-3.2.0-py${pVersion}-linux-x86_64.egg" ] && [ ! -f "/usr/lib/python${pVersion}/site-packages/Pillow-3.2.0-py${pVersion}-linux-x86_64.egg" ];then wget $download_Url/install/src/Pillow-3.2.0.zip -T 10 unzip Pillow-3.2.0.zip rm -f Pillow-3.2.0.zip cd Pillow-3.2.0 python setup.py …

宝塔面板安装脚本
type: item
date: 2022-06-09T21:33:00+08:00
description: #!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH LANG=en_US.UTF-8 if [ $(whoami) != "root" ];then echo "请使用root权限执行宝塔安装命令！" exit 1; fi is64bit=$(getconf LONG_BIT) if [ "${is64bit}" != '64' ];then Red_Error "抱歉, 当前面板版本不支持32位系统, 请使用64位系统或安装宝塔5.9!"; fi Centos6Check=$(cat /etc/redhat-release | grep ' 6.' | grep -iE 'centos|Red Hat') if [ "${Centos6Check}" ];then echo "Centos6不支持安装宝塔面板，请更换Centos7/8安装宝塔面板" exit 1 fi UbuntuCheck=$(cat /etc/issue|grep Ubuntu|awk '{print $2}'|cut -f 1 -d '.') if [ "${UbuntuCheck}" -lt "16" ];then echo "Ubuntu ${UbuntuCheck}不支持安装宝塔面板，建议更换Ubuntu18/20安装宝塔面板" exit 1 fi cd ~ setup_path="/www" python_bin=$setup_path/server/panel/pyenv/bin/python cpu_cpunt=$(cat /proc/cpuinfo|grep processor|wc -l) if [ "$1" ];then IDC_CODE=$1 fi GetSysInfo(){ if [ -s "/etc/redhat-release" ];then SYS_VERSION=$(cat /etc/redhat-release) elif [ -s "/etc/issue" ]; then SYS_VERSION=$(cat /etc/issue) fi SYS_INFO=$(uname -a) SYS_BIT=$(getconf LONG_BIT) MEM_TOTAL=$(free -m|grep Mem|awk '{print $2}') CPU_INFO=$(getconf _NPROCESSORS_ONLN) echo -e ${SYS_VERSION} echo -e Bit:${SYS_BIT} Mem:${MEM_TOTAL}M Core:${CPU_INFO} echo -e ${SYS_INFO} echo -e "请截图以上报错信息发帖至论坛www.bt.cn/bbs求助" } Red_Error(){ echo '================================================='; printf '\033[1;31;40m%b\033[0m\n' "$@"; GetSysInfo exit 1; } Lock_Clear(){ if [ -f "/etc/bt_crack.pl" ];then chattr -R -ia /www chattr -ia /etc/init.d/bt \cp -rpa /www/backup/panel/vhost/* /www/server/panel/vhost/ mv /www/server/panel/BTPanel/__init__.bak /www/server/panel/BTPanel/__init__.py rm -f /etc/bt_crack.pl fi } Install_Check(){ if [ "${INSTALL_FORCE}" ];then return fi echo -e "----------------------------------------------------" echo -e "检查已有其他Web/mysql环境，安装宝塔可能影响现有站点及数据" echo -e "Web/mysql service is alreday installed,Can't install panel" echo -e "----------------------------------------------------" echo -e "已知风险/Enter yes to force installation" read -p "输入yes强制安装: " yes; i…

群晖开机启动docker宝塔和nginx
type: item
date: 2021-12-31T14:28:00+08:00
description: 1.编写启动docker宝塔面板脚本以下终端命令，在docker服务启动后执行，可以启动容器内 宝塔服务 , bt-centos 为含有宝塔的docker 容器名 。这两行命令保存为 starng.sh ，且存放在 /volume1/docker/mx_baota/starng.sh 路径下，在 群晖管理界面 的 File Station 路径为 /docker/mx_baota/starng.shdocker exec bt-centos /etc/init.d/bt start docker exec bt-centos /etc/init.d/nginx start2.添加群晖计划任务控制面板 > 计划任务 > 新增 > 触发的任务 > 用户定义的脚本打开控制面板、计划任务新增计划任务用户账号必须选择 root （否则权限不足），事件选择 开机 新增计划任务勾选并填写邮箱，可以发送运行结果sleep 30 sh /volume1/docker/mx_baota/starng.sh

ubuntu宝塔面板安装nginx-rtmp-module
type: item
date: 2021-12-08T20:23:00+08:00
description: 1.从git上下载nginx-rtmp模块git clone https://github.com/arut/nginx-rtmp-module.git{alert type="error"}注意： 千万不要 先在windows平台下载rtmp模块文件，然后打包迁移到linux系统。否则文件编码格式将会被改变，怎么安装都不会成功。会出现错误提示：unknown directive "rtmp" {/alert}若没有安装git和gcc编译环境apt install -y gcc gcc-c++ autoconf wget apt -y install wget gcc-c++ ncurses ncurses-devel cmake make perl bison openssl openssl-devel gcc* libxml2 libxml2-devel curl-devel libjpeg* libpng* freetype*apt install -y git2.编译安装nginx时添加nginx-rtmp模块从宝塔中安装nginx中安装，选择编译安装，会出现自定义模块界面，点击添加，在弹出的界面输入：{alert type="error"}模块名称： nginx_rtmp_module 描述： nginx rtmp 参数： –add-module=/www/server/nginx-rtmp-module {/alert}验证：看到 --add-module=/allroot/programs/nginx-rtmp-module 另一种安装方式：修改 /www/server/panel/install/nginx.sh 安装命令，需要先用宝塔执行过编译安装命令后才会有该文件/www/server/panel/install然后执行安装命令sh /www/server/panel/install/nginx.sh install 1.203.修改nginx.conf配置rtmp_auto_push on; rtmp { server { listen 1935; #监听端口，记得开放 ping 30s; chunk_size 4000; notify_method get; application hls {#rtmp推流请求路径 live on; hls on; hls_path /www/server/nginx/hls; #视频流暂存地址 hls_sync 100ms; hls_fragment 5s; #切片大小，越小占用资源越高，但是延时越小，默认5s } application live { live on; } # Video on demand #application vod { # play /www/server/nginx/Videos; #} # Video on demand over HTTP #application vod_http { # play http://localhost:8080/vod/; #} } }#rtmp状态 location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { #rtmp-module模块安装地址，这个可以通过http看到状态 root /allroot/programs/nginx-rtmp-module; } #http支持hls流播放 location /hls { #Serve HLS config types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; } root /allroot/programs/live/hls; #与视频流暂存地址相同 expires -1; add_header Cache-Control no-cache; } 4.测hi推流ffmpeg -re -i test.flv -vcodec copy -acodec copy -f flv rtmp://10.163.102.157:1936/hls/test点播模型rtmp { server { listen 1935; #//服务端口 chunk_size 4096; #//数据传输块的大小 application video { play /usr/local/data/video; #//视频文件存放位置，访问方式rtmp://localhost:1935/video } } }5.直播回放rtmp { server { listen 1935; chunk_size 4096; appli…

Nginx配置tcp请求端口转发
type: item
date: 2021-11-14T17:59:57+08:00
description: stream { # 添加socket转发的代理 upstream socket_proxy { hash $remote_addr consistent; # 转发的目的地址和端口 server 192.168.1.100:9000 weight=5 max_fails=3 fail_timeout=30s; } # 提供转发的服务，即访问localhost:9001，会跳转至代理socket_proxy指定的转发地址 server { listen 9001; proxy_connect_timeout 1s; proxy_timeout 3s; proxy_pass socket_proxy; } }

docker运行宝塔面板
type: item
date: 2021-11-13T18:04:20+08:00
description: docker run -d -i -t --name baota -p 80:80 -p 443:443 -p 22:22 -p 18888:8888 -p 3307:3306 -p 3087:3087 -p 3088:3088 p 3089:3089 pch18/baota:clear