centos6.8 python2.6.6 升级到2.7.4

# 查看python 版本
python -V
# 安装一些依赖

yum install readline-devel sqlite-devel bzip2-devel.i686 openssl-devel.i686 gdbm-devel.i686 libdbi-devel.i686 ncurses-libs zlib-devel.i686

yum install yum-utils createrepo yum-plugin-priorities -y 

wget http://zlib.net/zlib-1.2.11.tar.gz
tar zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install
cd /tmp/
wget http://python.org/ftp/python/2.7.4/Python-2.7.4.tar.bz2 # 下载python2.7.4

tar -jxvf /tmp/Python-2.7.4.tar.bz2  # 解压到当前目录 /tmp/ 

cd Python-2.7.4

./configure --with-zlib && make all && make install  && make clean  && make distclean

# 系统认python指向python2.7
mv /usr/bin/python /usr/bin/python2.6.6  
ln -s /usr/local/bin/python2.7 /usr/bin/python 

# 至此,python2.7.4已经安装完毕。但是因为系统认python版本已经修改为2.7.4,而yum所需python版本兼容

# 将/usr/bin/yum 第一行的
# #!/usr/bin/python 改成
# #!/usr/bin/python2.6.6
# 先在第一行增加 #!/usr/bin/python2.6.6 
# 然后删除第二行
sed -i 'N;2i#!/usr/bin/python2.6.6' /usr/bin/yum  && sed -i '2d' /usr/bin/yum

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native