This commit is contained in:
Your Name
2026-07-23 17:56:25 +08:00
parent a05dae8412
commit 4970d8f8d3
4262 changed files with 735221 additions and 0 deletions
+65
View File
@@ -0,0 +1,65 @@
#!/usr/bin/env bash
# 在无宝塔 pyenv 的 CentOS 上编译安装 Python 3.11(需 root
# 用法: chmod +x scripts/install_python311.sh && ./scripts/install_python311.sh
set -euo pipefail
PYVER="3.11.9"
PY_SHORT="3.11"
PREFIX="/usr/local/python${PY_SHORT}"
PY_BIN="${PREFIX}/bin/python${PY_SHORT}"
SRC="/usr/src/Python-${PYVER}"
if [ "$(id -u)" -ne 0 ]; then
echo "[错误] 请用 root 运行"
exit 1
fi
if [ -x "$PY_BIN" ]; then
echo "[OK] 已存在 $PY_BIN"
"$PY_BIN" -c "import sys,ssl; print(sys.version); print(ssl.OPENSSL_VERSION)"
echo
echo "安装项目依赖:"
echo " cd /home/www/wwwroot/douyin"
echo " KEFU_PYTHON=$PY_BIN ./install.sh"
exit 0
fi
echo "========================================"
echo " 编译安装 Python ${PYVER}"
echo " 安装路径: ${PREFIX}"
echo "========================================"
if command -v yum &>/dev/null; then
yum groupinstall -y "Development Tools" || yum install -y gcc make
yum install -y openssl-devel bzip2-devel libffi-devel zlib-devel \
readline-devel sqlite-devel xz-devel wget tar
elif command -v apt-get &>/dev/null; then
apt-get update
apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev libffi-dev wget tar
else
echo "[错误] 不支持的系统,请手动安装编译依赖"
exit 1
fi
mkdir -p /usr/src
cd /usr/src
if [ ! -f "Python-${PYVER}.tgz" ]; then
wget -q "https://www.python.org/ftp/python/${PYVER}/Python-${PYVER}.tgz"
fi
rm -rf "$SRC"
tar xzf "Python-${PYVER}.tgz"
cd "$SRC"
./configure --prefix="$PREFIX" --enable-optimizations --with-openssl=/usr
make -j"$(nproc 2>/dev/null || echo 2)"
make altinstall
echo
echo "[OK] 安装完成"
"$PY_BIN" -c "import sys,ssl; print(sys.version); print('OpenSSL:', ssl.OPENSSL_VERSION)"
echo
echo "下一步:"
echo " cd /home/www/wwwroot/douyin"
echo " rm -rf backend/.venv"
echo " KEFU_PYTHON=$PY_BIN ./install.sh"