首页 > 代码库 > centos6.5升级python为2.7
centos6.5升级python为2.7
今天线上服务器全部升级python环境为python-2.7.6的环境,我采用的方法是ansible+shell,代码如下,友提,Python-2.7.6.tgz、setuptools-14.3.1.tar.gz、pip-9.0.1.tar.gz,这三个包我是提前下好放在/data/x5online/tools目录下,当然你也可以直接在脚本中wget相关包,个人喜欢把包下好了然后统一放在/data/x5online/tools目录里,脚本比较简单,记录下,省的又忘了,节约时间。时间就是金钱啊
#!/bin/bash yum install python-devel zlib-devel -y cd /data/x5online/tools tar xf Python-2.7.6.tgz cd Python-2.7.6 echo "开始编译python" ./configure --prefix=/usr/local make if [ $? -eq 0 ];then echo "make is ok" else echo "something is wrong" exit fi make install if [ $? -eq 0 ];then echo "make install is ok" else echo "something is wrong" exit fi ln -s /usr/local/python2.7 /usr/bin/python sleep 1 echo "开始安装setuptools" cd /data/x5online/tools tar xf setuptools-14.3.1.tar.gz cd setuptools-14.3.1 python setup.py install if [ $? -eq 0 ];then echo "setup is ok" else echo "something is wrong" exit fi sleep 1 echo "开始安装pip" cd /data/x5online/tools tar xf pip-9.0.1.tar.gz cd pip-9.0.1 python setup.py install if [ $? -eq 0 ];then echo "all is ok" else echo "something is wrong" fi
然后使用ansible all -m copy "src=http://www.mamicode.com/data/x5online/install_python.sh dest=/data/x5online"分发至所有需要升级python的服务器
最后ansible all -m shell "/data/x5online/install_python.sh"执行脚本。
centos6.5升级python为2.7
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。