public
Last active

  • Download Gist
install_python_on_shared_host.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
# Install python and some binary-dependencies from source in the user directory
# useful for Django webapps on shared hosts like Dreamhost
 
# BerkelyDB v 4.8 is supported by python 2.7 but not 5.3
# In addition, the bsddb module was deprecated in Python 2.6 and will be removed in 3.0
# So all this BDB stuff isn't useful, but does no harm
# linuxfromscratch.com has patch that can make python 2.7 work with BerkelyDB, if you need it
BDBVER=5.3.21
BDBVE=5.3
export LDFLAGS="-L$HOME/local/lib -L$HOME/local/BerkeleyDB.$BDBVE/lib"
export CPPFLAGS="-I$HOME/local/include -I$HOME/local/BerkeleyDB.$BDBVE/include"
export CXXFLAGS=$CPPFLAGS
export CFLAGS=$CPPFLAGS
export LD_LIBRARY_PATH=$HOME/local/lib:$HOME/local/BerkeleyDB.$BDBVE/lib
export LD_RUN_PATH=$LD_LIBRARY_PATH
 
mkdir -p ~/bin ~/tmp ~/local
 
# _tkinter = TCL and TK
# TCL = Tool Command Language -- a dynamic programming langage
# TK = GUI Toolkit for TCL
# Berkeley DB build needs _tkinter so install TCL first
# may need to scrape a source-forge page to get the latest version
VER=8.6.0
cd ~/tmp
wget http://prdownloads.sourceforge.net/tcl/tcl$VER-src.tar.gz
tar zxvf tcl$VER-src.tar.gz
cd tcl$VER/unix
./configure --prefix=$HOME/local
make
make install
cd ~/tmp
wget http://prdownloads.sourceforge.net/tcl/tk$VER-src.tar.gz
tar zxvf tk$VER-src.tar.gz
cd tk$VER/unix
./configure --prefix=$HOME/local
make
make install
 
VER=$BDBVER
VE=$BDBVE
cd ~/tmp
wget http://download.oracle.com/berkeley-db/db-$VER.tar.gz
tar zxvf db-$VER.tar.gz
cd db-$VER/build_unix
../dist/configure --prefix=$HOME/local/BerkeleyDB.$VE --enable-tcl --with-tcl=$HOME/local/lib
make
make install
 
VER=1.0.6
VE=1.0
cd ~/tmp
wget http://www.bzip.org/$VER/bzip2-$VER.tar.gz
tar zxvf bzip2-$VER.tar.gz
cd bzip2-$VER
make -f Makefile-libbz2_so
make
make install PREFIX=$HOME/local
cp ./libbz2.so.$VER $HOME/local/lib
ln -s $HOME/local/lib/libbz2.so.$VER $HOME/local/lib/libbz2.so.$VE
 
VER=2.7.3
VE=2.7
cd ~/tmp
wget http://python.org/ftp/python/$VE/Python-$VE.tgz
tar zxvf Python-$VE.tgz
cd Python-$VE
./configure --prefix=$HOME/local/Python-$VE
make
make install
 
rm -rf ~/tmp/*
 
cd ~
echo "export PATH=\"$HOME/local/bin:\$PATH\"" >> .bashrc
echo "export PATH=\"$HOME/local/Python-$VE/bin:\$PATH\"" >> .bashrc
source .bashrc

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.