Today online server All upgrade Python environment for python-2.7.6 Environment, I use the method is Ansible+shell, code as follows, friend, Python-2.7.6.tgz, setuptools-14.3.1.tar.gz, Pip-9.0.1.tar.gz, these three bags I was in advance under the/data/x5online/tools directory, of course, you can also directly in the script wget related packages, the individual likes to put the package and then unified in the/data/x5online/ Tools directory, the script is relatively simple, record, save and forget, save time. Time is money.
#!/bin/bashyum install python-devel Zlib-devel-ycd/data/x5online/toolstar XF python-2.7.6.tgzcd Python-2.7.6echo " Start compiling python "./configure--prefix=/usr/localmake if [$?-eq 0];then echo" Make was OK "else echo" Something is wrong " exitfimake InstallIf [$?] -eq 0];then echo "Make install was OK" else echo "Something is wrong" exitfiln-s/usr/local/python2.7/usr/bin /pythonsleep 1echo "Start installing 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 ' start installation P IP "Cd/data/x5online/toolstar XF pip-9.0.1.tar.gzcd pip-9.0.1python setup.py installif [$?-eq 0];then echo" All are OK "Else echo" Something is wrong "fi
Then use ansible all-m copy "src=/data/x5online/install_python.sh Dest=/data/x5online" to distribute to all servers that need to upgrade Python
Finally ansible all-m Shell "/data/x5online/install_python.sh" executes the script.
centos6.5 upgrade Python to 2.7