centos6.5升級python為2.7

來源:互聯網
上載者:User

標籤:figure   shel   .sh   data   sleep   something   highlight   wrong   python2.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/bashyum install python-devel zlib-devel -ycd /data/x5online/toolstar xf Python-2.7.6.tgzcd Python-2.7.6echo "開始編譯python"./configure --prefix=/usr/localmake if [ $? -eq 0 ];then    echo "make is ok"else    echo "something is wrong"    exitfimake installif [ $? -eq 0 ];then    echo "make install is ok"else    echo "something is wrong"    exitfiln -s /usr/local/python2.7 /usr/bin/pythonsleep 1echo "開始安裝setuptools"cd /data/x5online/toolstar xf setuptools-14.3.1.tar.gzcd setuptools-14.3.1python setup.py installif [ $? -eq 0 ];then    echo "setup is ok"else    echo "something is wrong"    exitfisleep 1echo "開始安裝pip"cd /data/x5online/toolstar xf pip-9.0.1.tar.gzcd pip-9.0.1python setup.py installif [ $? -eq 0 ];then    echo "all is ok"else    echo "something is wrong"fi

然後使用ansible all -m copy "src=/data/x5online/install_python.sh dest=/data/x5online"分發至所有需要升級python的伺服器

最後ansible all -m shell "/data/x5online/install_python.sh"執行指令碼。

centos6.5升級python為2.7

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.