Install the dependency package before installing:
Yum Groupinstall "Development tools"
Yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel Libpcap-devel Xz-devel
wget--no-check-certificate https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz
You need to pay special attention here, because the download URL is the beginning of HTTPS, so you want to add the--no-check-certificate parameter to the wget command.
After downloading the good source package, unzip:
TAR-ZXVF./python-2.7.8.tgz
After extracting the Python-2.7.8 directory, we started compiling the source code:
CD Python-2.7.8
./configure--prefix=/usr/local/python
Make
Make install
After compiling the installation, replace the python that comes with the system, but the CentOS Yum relies on Python, and in order to keep Yum running, we need to rename our own Python backup before replacing it with the following method:
mv/usr/bin/python/usr/bin/python-2.4.3
Ln-s/usr/local/python/bin/python/usr/bin/python
After the above two lines of commands are executed, you can use "python-v" and "/usr/bin/python-2.4.3-v" respectively to verify the success of the deployment, and the correct result should be 2.7.8 and 2.4.3.
Finally, to modify Yum, let it run to the old version:
Vi/usr/bin/yum
Modify "#!/usr/bin/python" in the first row to "#!/usr/bin/python-2.4.3" and save
CentOS installs python2.7.8, and Yum does not expire