Last active
March 20, 2019 05:40
-
-
Save jimyang2008/5241f2a5ed78a8e64155773b0a31e03c to your computer and use it in GitHub Desktop.
install Python 2.7 and Pip without root access
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
INSTALL_DIR=~/opt/python | |
TMP_DIR=/tmp/install_python | |
mkdir -p $INSTALL_DIR | |
DIR_OPENSSL=openssl-1.0.2k | |
DIR_PYTHON=Python-2.7.13 | |
FILE_OPENSSL=${DIR_OPENSSL}.tar.gz | |
FILE_PYTHON=${DIR_PYTHON}.tgz | |
FILE_PIP=get-pip.py | |
FTP_BASE=ftp://ftp.yangjian.net/pub | |
URL_OPENSSL=$FTP_BASE/$FILE_OPENSSL | |
URL_PYTHON=$FTP_BASE/$FILE_PYTHON | |
URL_PIP=$FTP_BASE/$FILE_PIP | |
mkdir -p $TMP_DIR | |
cd $TMP_DIR | |
echo '- downloading packages' | |
curl -sLOk $URL_OPENSSL | |
curl -sLOk $URL_PYTHON | |
curl -sLOk $URL_PIP | |
echo '- install openssl' | |
tar -xzf $FILE_OPENSSL | |
( | |
cd $DIR_OPENSSL | |
./config --prefix=$INSTALL_DIR/ssl --openssldir=$INSTALL_DIR/ssl | |
make && make install | |
) | |
echo '- install python' | |
tar -xzf $FILE_PYTHON | |
( | |
cd $DIR_PYTHON | |
# update Modules/Setup.dist with following changes | |
# - uncomment SSL lines | |
# - set SSL to value of "$INSTALL_DIR/ssl" | |
./configure --prefix=$INSTALL_DIR | |
make && make install | |
) | |
export PATH=$INSTALL_DIR/bin:$PATH | |
cat <<EOS >> ~/.bashrc | |
export PATH=$INSTALL_DIR/bin:\$PATH | |
EOS | |
echo '- install pip' | |
python $FILE_PIP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment