正文
#! /bin/bash
# filename: python-instaler.sh
SOURCE_PATH=/usr/local/source
# 下载源码包
mkdir -p $SOURCE_PATH
curl -o $SOURCE_PATH/Python-3.11.9.tgz https://www.python.org/ftp/python/3.11.9/Python-3.11.9.tgz
# 解压
tar zxvf $SOURCE_PATH/Python-3.11.9.tgz -C $SOURCE_PATH
# 安装编译依赖
yum install -y gcc make
# 安装依赖
dnf install -y \
openssl openssl-devel openssl-static \
bzip2 bzip2-devel \
ncurses ncurses-devel \
readline readline-devel \
xz lzma xz-devel \
sqlite sqlite-devel \
gdbm gdbm-devel \
expat-devel \
tk tk-devel \
tcl tcl-devel \
libffi libffi-devel \
libnsl libnsl2-devel \
uuid libuuid-devel
# 编译安装
cd $SOURCE_PATH/Python-3.11.9
mkdir -p /usr/local/python/python3.11.9
./configure --enable-shared --prefix=/usr/local/python/python3.11.9 --enable-optimizations
make && make install
# 添加环境变量
echo 'export PATH="$PATH:/usr/local/python/python3.11.9/bin"' >> /etc/profile
cp -f libpython3.11.so.1.0 /lib64
cd -