# 查看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