安装部署Python脚本

安装部署Python脚本

#!/bin/bash
#该脚本是源码安装Python
   echo "正在安装,请稍后"
   echo "安装依赖包"
   yum -y install gcc gcc-c++ make zlib-devel bzip2-devel openssl-devel  sqlite-devel readline-devel  libffi-devel wget
   echo "安装依赖包完成"
   echo "正在下载源码"
   wget https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tar.xz
   echo "正在检查是否下载完成"
if [ -f /Python-3.7.6.tar.xz  ];then
   echo "Python下载完成"
else
   echo "下载失败请检查"
fi
   echo "解压安装包"
  tar -xf Python-3.7.6.tar.xz
   cd Python-3.7.6
        echo "正在修改配置文件"
        sed -ri 's/^#readline/readline/' Modules/Setup.dist
        sed -ri 's/^#(SSL=)/\1/' Modules/Setup.dist
        sed -ri 's/^#(_ssl)/\1/' Modules/Setup.dist
        sed -ri 's/^#([\t]*-DUSE)/\1/' Modules/Setup.dist
        sed -ri 's/^#([\t]*-L\$\(SSL\))/\1/' Modules/Setup.dist
   echo "正在进行源码编译"
        ./configure --enable-shared
        make -j 1 && make install
   echo "正在配置环境"
file="/etc/profile.d/python3_lib.sh"  # 定义
        echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib' >$file
        path="/usr/local/lib/"
        file2="/etc/ld.so.conf.d/python3.conf"
        echo $path > $file2
        ldconfig
        source /etc/profile

        a= `python3 -V`
        python3 -V &> /dev/null
if [ $? -eq 0 ];then
echo "$a 安装成功 请输入python3 -V"
  else
echo "$a 安装失败"
        exit
fi

你可能感兴趣的:(linux,python,centos,nginx,docker)