Centos 一键编译安装python
代码如下:
#!/bin/bash
#auth:jiang_feng
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 wget gcc
cd /usr/local/src
wget https://www.python.org/ftp/python/3.6.7/Python-3.6.7.tgz
tar xf Python-3.6.7.tgz
cd Python-3.6.7
./configure --prefix=/usr/local/python
make && make install
#软链接
ln -s /usr/local/python/bin/python3 /usr/bin/python3
ln -s /usr/local/python/bin/pip3 /usr/bin/pip3
#加入环境变量
echo "PATH=$PATH:$HOME/bin:/usr/local/python/bin" >> /etc/profile
注:wget下载可能会很慢,或者超时。
解决办法:可以下载到本地,注释wget行,更改下相关的版本信息在执行此脚本