Compile Python 2.7, OpenSSL and zlib with a Custom Prefix

First, export an environment variable with your prefix:

1
export MY_PREFIX=$HOME/python27

Configure, make and install zlib:

1
2
3
4
5
tar xf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --prefix=$MY_PREFIX
make -j4
make install

Configure, make and install OpenSSL:

1
2
3
4
5
tar xf openssl-1.0.2f.tar.gz
cd openssl-1.0.2f
./config shared --prefix=$MY_PREFIX
make -j4
make install

Configure, make and install Python:

1
2
3
4
5
6
7
8
tar xf Python-2.7.11.tar.xz
cd Python-2.7.11
LDFLAGS="-L$MY_PREFIX/lib -L$MY_PREFIX/lib64 -Wl,-rpath=$MY_PREFIX/lib" \
LD_LIBRARY_PATH="$MY_PREFIX/lib:$MY_PREFIX/lib64" \
CPPFLAGS="-I$MY_PREFIX/include -I$MY_PREFIX/ssl" \
./configure --prefix=$MY_PREFIX --enable-shared
make -j4
make install

Check that it was installed correctly:

1
2
3
4
export PATH=$MY_PREFIX/bin:$PATH
which python
python --version
python