Skip to content

Instantly share code, notes, and snippets.

@vifo
Created April 13, 2012 18:01
Show Gist options
  • Save vifo/2378829 to your computer and use it in GitHub Desktop.
Save vifo/2378829 to your computer and use it in GitHub Desktop.
Configure, build and install ImageMagick 6.7.6.5 + PHP Imagick 2.3.0 under Ubuntu 10.04.4 LTS (with VPS OpenMP performance workaround)
#!/bin/sh
# ------------------------------------------------------------------------
# Configure, build and install ImageMagick 6.7.6.5 and PHP Imagick 2.3.0
# under Ubuntu 10.04.4 LTS.
#
# This script will automatically download, configure and build both
# software packages mentioned above and install them in /usr/local.
#
# In order to address performance problems with VPS systems and OpenMP,
# OpenMP will be dissabled. See following links for more information:
#
# http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=17302
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=638409
# http://johannes.jarolim.com/blog/2011/11/21/extreme-slow-imagemagick-on-vps-with-ubuntu/
#
# ATTENTION: Any files in /usr/local/imagemagick-6.7.6.5 will be removed
# without confirmation.
# ------------------------------------------------------------------------
IMAGEMAGICK_VERSION="6.7.6-5"
IMAGICK_VERSION="2.3.0"
IMAGEMAGICK_PREFIX="/usr/local/imagemagick-${IMAGEMAGICK_VERSION}"
IMAGICK_PREFIX="/usr/local/imagick-${IMAGICK_VERSION}"
export CC=gcc
export CXX=g++
export CFLAGS="-march=native -Wall -pipe"
export CXXFLAGS="-march=native -Wall -pipe"
export PATH=/usr/local/perl-5.14.2/bin:$PATH
function build_imagemagick() {
BUILDDIR=$(mktemp -d)
echo "------------------------------------------------------------------------------"
echo "Building ImageMagick ${IMAGEMAGICK_VERSION} in ${BUILDDIR}"
echo "------------------------------------------------------------------------------"
cd ${BUILDDIR}
wget http://www.imagemagick.org/download/ImageMagick-${IMAGEMAGICK_VERSION}.tar.bz2
tar -xjf ImageMagick-${IMAGEMAGICK_VERSION}.tar.bz2
cd ImageMagick-${IMAGEMAGICK_VERSION}
./configure \
--prefix=${IMAGEMAGICK_PREFIX} \
--without-wmf \
--without-x \
--without-gvc \
--without-jbig \
--without-lcms \
--without-lcms2 \
--without-rsvg \
--without-webp \
--disable-openmp \
--disable-opencl \
--with-magick-plus-plus \
--with-perl=/usr/local/perl-5.14.2/bin/perl
make -j3
make install
# compress manpages
find ${IMAGEMAGICK_PREFIX}/share/man/man1 -name '*.1' | xargs --no-run-if-empty gzip -9
# add library path to ld.so.conf.d
cat >/etc/ld.so.conf.d/imagemagick-${IMAGEMAGICK_VERSION}.conf <<EOF
/usr/local/imagemagick-${IMAGEMAGICK_VERSION}/lib
EOF
ldconfig
rm -rf ${BUILDDIR}
}
function build_imagick() {
BUILDDIR=$(mktemp -d)
echo "------------------------------------------------------------------------------"
echo "Building PHP imagick ${IMAGICK_VERSION} in ${BUILDDIR}"
echo "------------------------------------------------------------------------------"
cd ${BUILDDIR}
wget http://pecl.php.net/get/imagick-${IMAGICK_VERSION}.tgz
tar -xzf imagick-${IMAGICK_VERSION}.tgz
cd imagick-${IMAGICK_VERSION}
phpize5
./configure \
--with-imagick=${IMAGEMAGICK_PREFIX} \
--prefix=${IMAGICK_PREFIX}
make -j3
make install
cat >/etc/php5/apache2/conf.d/imagick.ini <<EOF
extension=imagick.so
EOF
rm -rf ${BUILDDIR}
}
function install_prereqs {
apt-get update
apt-get install build-essential libbz2-dev libexif-dev libfreetype6-dev libjpeg-dev libpng-dev libtiff-dev libxml2-dev zlib1g-dev
}
install_prereqs
build_imagemagick
build_imagick
# vim: set sw=4 ts=4 sts=4 et:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment