-
-
Save lukeorland/8ec48debbbcefbd38b90 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
#---------------------------------------# | |
# Python 2.7.3 Install on CentOS 5 # | |
# https://gist.github.com/timss/5122008 # | |
# # | |
# Installs to /usr/local/{bin,lib} # | |
# Seperate from system default # | |
# /usr/bin/python(2.4) # | |
#---------------------------------------# | |
# Exit install script if any command fails | |
set -e | |
# Require root privileges | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root." | |
exit 1 | |
fi | |
# Continue confirmation + warning | |
echo -e \ | |
"This script will install Python2.7.3 on CentOS 5.x | |
Files will be (alt)installed to /usr/local/{bin,lib}, | |
seperate from system default /usr/bin/python(2.4)\n | |
Affected files are (which you might want to backup): /etc/ld.so.conf\n" | |
read -p "Continue? [y/N]: " | |
# Could've done ${REPLY,,} but CentOS has a very outdated bash (2005) | |
if [[ !(${REPLY} =~ ^(y|Y)$) ]]; then | |
echo -e "Quitting..." | |
exit 0 | |
fi | |
# Install required packages for compilation | |
yum groupinstall "Development tools" | |
yum install {zlib,bzip2,openssl,ncurses,sqlite}-devel | |
# Download Python 2.7.3 source code | |
cd /tmp | |
mkdir python273 | |
cd python273 | |
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2 | |
tar -xf Python-2.7.3.tar.bz2 | |
cd Python-2.7.3 | |
# Patch for _sqlite module - http://bugs.python.org/issue14572 | |
curl http://bugs.python.org/file25647/sqlite3_int64_v2.patch | patch -p1 | |
# Configure with shared libraries, used by mod_wsgi | |
./configure --prefix=/usr/local --enable-shared | |
# Compile and install | |
make | |
make altinstall # *NOT* install, very important! | |
# Fix path to shared lib - http://stackoverflow.com/a/7880519/1076493 | |
echo "/usr/local/lib" >> /etc/ld.so.conf | |
ldconfig | |
# Install distribute - http://stackoverflow.com/a/10538341/1076493 | |
wget http://python-distribute.org/distribute_setup.py | |
python2.7 distribute_setup.py | |
# Install pip, because easy_install is deprecated | |
# http://trizpug.org/Members/cbc/wyntkap/img/pip_distribute.png | |
easy_install-2.7 pip # delete? | |
# Install virtualenv and other interesting packages | |
# will be added to /usr/local/bin/ | |
pip install virtualenv yolk bpython | |
# Clean up | |
rm -rf /tmp/python273 | |
# Done! | |
echo "Installation of Python 2.7.3 Done!" |
This file contains hidden or 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 | |
#---------------------------------------# | |
# Python 2.7.3 Install on CentOS 5 # | |
# https://gist.github.com/timss/5122008 # | |
# # | |
# Alternative version used for intranet # | |
# that has a local repo mirror # | |
# # | |
# Installs to /usr/local/{bin,lib} # | |
# Seperate from system default # | |
# /usr/bin/python(2.4) # | |
# # | |
# Requires this in /tmp/python273/ # | |
# - Python-2.7.3.tar.bz2 # | |
# - sqlite3_int64_v2.patch # | |
# - distribute-*.tar.gz # | |
# - pip-*.tar.gz # | |
# - virtualenv-*.tar.gz # | |
#---------------------------------------# | |
# Exit install script if any command fails | |
set -e | |
# Require root privileges | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root." | |
exit 1 | |
fi | |
# Continue confirmation + warning | |
echo -e \ | |
"This script will install Python2.7.3 on CentOS 5.x | |
Files will be (alt)installed to /usr/local/{bin,lib}, | |
seperate from system default /usr/bin/python(2.4)\n | |
Affected files are (which you might want to backup): /etc/ld.so.conf\n" | |
read -p "Continue? [y/N]: " | |
# Could've done ${REPLY,,} but CentOS has a very outdated bash (2005) | |
if [[ !(${REPLY} =~ ^(y|Y)$) ]]; then | |
echo -e "Quitting..." | |
exit 0 | |
fi | |
# Install required packages for compilation | |
yum groupinstall "Development tools" | |
yum install {zlib,bzip2,openssl,ncurses,sqlite}-devel | |
# Ready for compilation | |
cd /tmp/python273 | |
tar -xf Python-2.7.3.tar.bz2 | |
cd Python-2.7.3 | |
# Patch for _sqlite module - http://bugs.python.org/issue14572 | |
cat ../sqlite3_int64_v2.patch | patch -p1 | |
# Configure with shared libraries, used by mod_wsgi | |
./configure --prefix=/usr/local --enable-shared | |
# Compile and install | |
make | |
make altinstall # *NOT* install, very important! | |
# Fix path to shared lib - http://stackoverflow.com/a/7880519/1076493 | |
echo "/usr/local/lib" >> /etc/ld.so.conf | |
/sbin/ldconfig | |
# Install distribute - http://stackoverflow.com/a/10538341/1076493 | |
cd /tmp/python273 | |
tar -xzvf distribute-*.tar.gz | |
/usr/local/bin/python2.7 distribute-*/setup.py install | |
# Install pip, because easy_install is deprecated | |
# http://trizpug.org/Members/cbc/wyntkap/img/pip_distribute.png | |
/usr/local/bin/easy_install-2.7 pip-*.tar.gz | |
# Install virtualenv, will be added to /usr/local/bin/ | |
/usr/local/bin/pip install virtualenv-*.tar.gz | |
# Clean up | |
rm -rf /tmp/python273 | |
# Done! | |
echo "Installation of Python 2.7.3 Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment