快速编译安装配置 py2.7 & jdk 1.7



0x01 前言:
    有时迫于无奈,我们需要在目标机器上安装一些自己的工具环境,尤其是linux(默认python版本是2.6.6的,现在有些脚本已经很难跑起来),至于win,其平台下的工具已经非常丰富了,这里就不说了

0x02 编译安装python2.7:

1
2
3
4
5
6
7
8
9
10
11
12
# yum groupinstall "Development tools" -y
# yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel -y
# wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz
# tar xf Python-2.7.11.tgz
# cd Python-2.7.11
# ./configure --prefix=/usr/local
# make && make install
# echo $?
# python2.7
>>> import sys
>>> sys.version

0x03 在安装pip之前,我们需要先编译安装好setuptools:

1
2
3
4
# tar xf setuptools-21.0.0.tar.gz
# cd setuptools-21.0.0
# python setup.py install
# echo $?

0x04 开始编译安装pip:

1
2
3
4
# tar xf pip-8.1.1.tar.gz
# cd pip-8.1.1
# python setup.py install
# echo $?

0x05 简单测试下pip是否可用,随便装个库,看看好不好使:

1
2
# pip2.7 -h
# pip2.7 install requests

0x06 说完python,我们再来简单说下怎么在linux中快速配置jdk 1.7.x,非常简单,过程如下:

1
2
3
4
5
6
7
8
9
# tar xf jdk-7u45-linux-x64.tar.gz
# mv jdk1.7.0_45/ /usr/local/
# ln -s /usr/local/jdk1.7.0_45/ /usr/local/jdk
# ll /usr/local/jdk/
# vi /etc/profile
export JAVA_HOME=/usr/local/jdk/
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
# source /etc/profile