一、安装依赖库
yum install zlib zlib-devel -y
二、安装openssl(如果无法下载安装包,请×××,你懂得)
mkdir /usr/local/openssl && cd /usr/local/openssl && wget http://www.openssl.org/source/openssl-1.0.2f.tar.gz && tar zxvf openssl-1.0.2f.tar.gz && cd openssl-1.0.2f && ./config --prefix=/usr/local/openssl --shared && make && make install
三、Python安装
1、创建安装路径
mkdir -p /usr/local/python
2、进入到安装路径下载安装包并解压:
cd /usr/local/python && wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz && tar zxvf Python-2.7.8.tgz && cd Python-2.7.8
3、进入Modules目录修改配置文件Setup.dist,添加编译ssl模块
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
4、执行编译安装
./configure --prefix=/usr/local/python && make && make install
四、修改系统默认Python指向
mv /usr/bin/python /usr/bin/python_bak && ln -s /usr/local/python/bin/python2.7 /usr/bin/python
恢复:
rm -rf /usr/bin/python
mv /usr/bin/python_bak /usr/bin/python
五、安装EASY_INSTALL、PIP
wget https://pypi.python.org/packages/source/e/ez_setup/ez_setup-0.9.tar.gz && tar zxvf ez_setup-0.9.tar.gz && cd ez_setup-0.9 && /usr/local/python/bin/python2.7 ez_setup.py
wget https://pypi.python.org/packages/source/p/pip/pip-6.1.1.tar.gz#md5=6b19e0a934d982a5a4b798e957cb6d45 && tar zxvf pip-6.1.1.tar.gz && cd pip-6.1.1 && /usr/local/python/bin/python2.7 setup.py install
创建工具链接
ln -s /usr/local/python/bin/pip2 /usr/bin/pip
ln -s /usr/local/python/bin/easy_install /usr/bin/easy_install
六、
如果是Linux6的系统,需要修改yum的配置
vi /usr/bin/yum
#!/usr/bin/python
修改为:
#!/usr/bin/python2.6