CentOS7一键安装python3
一、更新OpenSSL
1、安装依赖,下载安装包
yum install -y gcc libffi-devel zlib* openssl-devel libffi-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make perl
wget --no-check-certificate https://www.openssl.org/source/openssl-1.1.1a.tar.gz
2、解压缩编译
tar -zxvf openssl-1.1.1a.tar.gz
cd openssl-1.1.1a/
./config --prefix=/usr/local/openssl
make && make install
3、配置
#删除原有的openssl
rm -rf /usr/bin/openssl
#给新安装的openss创建软连接
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/local/lib64/libssl.so
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
#写入openssl库文件的搜索路径
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
#使修改后的/etc/ld.so.conf生效
ldconfig -v
4、删除临时文件
cd ..
rm -rf openssl-1.1.1a/ openssl-1.1.1a.tar.gz
5、查看版本,如果还是旧版本重新连接会话即可
#查看openssl版本
openssl version
二、安装Python
以下是安装Python3的一键脚本:
# 安装python3一键脚本
# 适用系统 CentOS
# Python3版本:3.11.0
# 安装编译Python3源文件所需的编译环境
yum install -y gcc
yum install -y zlib*
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
# 下载并解压Python文件
wget http://cdn.npm.taobao.org/dist/python/3.11.0/Python-3.11.0.tgz
tar -zxvf Python-3.11.0.tgz
cd Python-3.11.0/
# 指定安装目录
./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl
# 编译并安装
make
make install
# 建立软链接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
# 清理文件
cd ..
rm -rf Python-3.11.0/ Python-3.11.0.tgz
echo "安装完成."
echo "安装目录:/user/local/pyhton3"
THE END
0
二维码
海报
CentOS7一键安装python3
一、更新OpenSSL
1、安装依赖,下载安装包
yum install -y gcc libffi-devel zlib* openssl-devel libffi-devel zlib-devel bzip2-devel openssl-devel ncurse……