Installing FFMPEG-PHP on Dreamhost PS

I have been trying for a few weeks now to install FFMPEG-PHP on my Dreamhost PS account, and I’ve gotten damn close. I finally contacted Todd Kirby, the creator of FFMPEG-PHP, and hired him to help out. This was the result. I haven’t tested it 100% yet, which is why it’s not on the Dreamhost wiki. Feedback welcome.

#!/bin/sh

# Script update 2009-09-22 by bhugh to work under dreamhost roughriders & include newer
#  versions of most items.
# Script updated 2008-09-23 by Skwerl (antiquiet.com) to work with dreamhost's debian etch
# Script updated 2007-11-24 by Andrew (ajmconsulting.net) to allow 3rd wget line to pass
# Script updated 2006-12-25 by Carl McDade (hiveminds.co.uk) to allow memory limit and freetype
# Script modified 2010-2-10 by Jeff Crouse (jeff@crouse.cc) to install FFMPEG-PHP also
# FFMPEG-PHP script by http://www.netbrix.net/archives/20
#
# LIBMCRYPT version information (was set as static download file name previously.)
#
# Save the code to a file as *.sh
# Abort on any errors
#
set -e

# The domain in which to install the PHP CGI script.
export DOMAIN="laborersoflove.com"

# Where do you want all this stuff built? I'd recommend picking a local
# filesystem.
# ***Don't pick a directory that already exists!***  We clean up after
# ourselves at the end!
SRCDIR=${HOME}/source

# Set DISTDIR to somewhere persistent, if you plan to muck around with this
# script and run it several times!
DISTDIR=${HOME}/dist

# Pre-download clean up!!!!
#rm -rf $SRCDIR $DISTDIR
#rm -rf $SRCDIR

# Update version information here.
PHP5="php-5.2.11"
LIBICONV="libiconv-1.13.1"
LIBMCRYPT="libmcrypt-2.5.8"
LIBXML2="libxml2-2.7.6"
LIBXSLT="libxslt-1.1.26"
MHASH="mhash-0.9.9.9"
ZLIB="zlib-1.2.3"
CURL="curl-7.18.2"
LIBIDN="libidn-1.9"
CCLIENT="imap-2004g"
CCLIENT_DIR="imap-2004g" # Another pest!
FREETYPE="freetype-2.3.7"
OPENSSL="openssl-0.9.8i"
AUTOCONF="autoconf-2.60"
LAME="lame-3.97"
RUBY="ruby-1.9.0-0"
LIBOGG="libogg-1.1.3"
LIBVORBIS="libvorbis-1.1.2"
GD="gd-2.0.33"
FLVTOOL2="flvtool2-1.0.6"
FFMPEGPHP="ffmpeg-php-0.6.0"
AMR="amrwb-7.0.0.2"
CODECS="essential-20071007"

# What PHP features do you want enabled?
PHPFEATURES="--prefix=$HOME
 --with-config-file-path=$HOME/etc/php5/${DOMAIN}
 --enable-fastcgi
 --enable-force-cgi-redirect
 --with-xml
 --with-libxml-dir=$HOME
 --with-freetype-dir=$HOME
 --enable-soap
 --with-openssl=$HOME
 --with-mhash=$HOME
 --with-mcrypt=$HOME
 --with-zlib-dir=$HOME
 --with-jpeg-dir=/usr
 --with-png-dir=/usr
 --with-gd
 --enable-gd-native-ttf
 --enable-memory-limit
 --enable-ftp
 --enable-exif
 --enable-sockets
 --enable-wddx
 --with-iconv=$HOME
 --enable-sqlite-utf8
 --enable-calendar
 --with-curl=$HOME
 --enable-mbstring
 --enable-mbregex
 --enable-bcmath
 --with-mysql=/usr
 --with-mysqli
 --without-pear
 --with-gettext
 --with-imap=$HOME
 --without-imap-ssl
 --libdir=$HOME/lib
 --bindir=$HOME/bin
 --with-ffmpeg=$HOME"

# ---- end of user-editable bits. Hopefully! ----

# Push the install dir's bin directory into the path
export PATH=$HOME/bin:$PATH
#export LD_LIBRARY_PATH=$HOME/lib:/usr/local/lib:$LD_LIBRARY_PATH
#export CPATH=$HOME/include:/usr/local/include:$CPATH
#export LIBRARY_PATH=$HOME/lib:/usr/local/lib:$LIBRARY_PATH

# set up directories
mkdir -p ${SRCDIR}
mkdir -p ${DISTDIR}
cd ${DISTDIR}

# Get all the required packages
echo Downloading ${PHP5}
if [ -f "${PHP5}.tar.gz" ]; then
 echo ${PHP5} has already been downloaded.
else
 wget -c http://us.php.net/get/${PHP5}.tar.gz/from/this/mirror
fi

echo Downloading ${LIBICONV}
if [ -f "${LIBICONV}.tar.gz" ]; then
 echo ${LIBICONV} has already been downloaded.
else
 wget -c http://mirrors.usc.edu/pub/gnu/libiconv/${LIBICONV}.tar.gz
fi

echo Downloading ${LIBMCRYPT}
if [ -f "${LIBMCRYPT}.tar.gz" ]; then
 echo ${LIBMCRYPT} has already been downloaded.
else
 wget -c http://easynews.dl.sourceforge.net/sourceforge/mcrypt/${LIBMCRYPT}.tar.gz
fi

echo Downloading ${LIBXML2}
if [ -f "${LIBXML2}.tar.gz" ]; then
 echo ${LIBXML2} has already been downloaded.
else
 wget -c ftp://xmlsoft.org/libxml2/${LIBXML2}.tar.gz
fi

echo Downloading ${LIBXSLT}
if [ -f "${LIBXSLT}.tar.gz" ]; then
 echo ${LIBXSLT} has already been downloaded.
else
 wget -c ftp://xmlsoft.org/libxml2/${LIBXSLT}.tar.gz
fi

echo Downloading mhash-0.9.9.9.tar.gz
if [ -f "${MHASH}.tar.gz" ]; then
 echo ${MHASH} has already been downloaded.
else
 wget -c http://downloads.sourceforge.net/project/mhash/mhash/0.9.9.9/${MHASH}.tar.gz
fi

echo Downloading ${ZLIB}
if [ -f "${ZLIB}.tar.gz" ]; then
 echo ${ZLIB} has already been downloaded.
else
 wget -c http://www.zlib.net/${ZLIB}.tar.gz
fi

echo Downloading ${CURL}
if [ -f "${CURL}.tar.gz" ]; then
 echo ${CURL} has already been downloaded.
else
 wget -c http://curl.haxx.se/download/${CURL}.tar.gz
fi

echo Downloading ${FREETYPE}
if [ -f "${FREETYPE}.tar.gz" ]; then
 echo ${FREETYPE} has already been downloaded.
else
 wget -c http://kent.dl.sourceforge.net/sourceforge/freetype/${FREETYPE}.tar.gz
fi

echo Downloading ${LIBIDN}
if [ -f "${LIBIDN}.tar.gz" ]; then
 echo ${LIBIDN} has already been downloaded.
else
 wget -c ftp://alpha.gnu.org/pub/gnu/libidn/${LIBIDN}.tar.gz
fi

echo Downloading ${CCLIENT}
if [ -f "${CCLIENT}.tar.Z" ]; then
 echo ${CCLIENT} has already been downloaded.
else
 wget -c ftp://ftp.cac.washington.edu/imap/old/${CCLIENT}.tar.Z
fi

echo Downloading ${OPENSSL}
if [ -f "${OPENSSL}.tar.gz" ]; then
 echo ${OPENSSL} has already been downloaded.
else
 wget -c http://www.openssl.org/source/${OPENSSL}.tar.gz
fi

echo Downloading ${AUTOCONF}
if [ -f "${AUTOCONF}.tar.gz" ]; then
 echo ${AUTOCONF} has already been downloaded.
else
 wget http://ftp.gnu.org/gnu/autoconf/${AUTOCONF}.tar.gz
fi

echo Downloading ${LAME}
if [ -f "${LAME}.tar.gz" ]; then
 echo ${LAME} has already been downloaded.
else
 wget http://nchc.dl.sourceforge.net/sourceforge/lame/${LAME}.tar.gz
fi

echo Downloading ${LIBOGG}
if [ -f "${LIBOGG}.tar.gz" ]; then
 echo ${LIBOGG} has already been downloaded.
else
 wget http://downloads.xiph.org/releases/ogg/${LIBOGG}.tar.gz
fi

echo Downloading ${LIBVORBIS}
if [ -f "${LIBVORBIS}.tar.gz" ]; then
 echo ${LIBVORBIS} has already been downloaded.
else
 wget http://downloads.xiph.org/releases/vorbis/${LIBVORBIS}.tar.gz
fi

echo Downloading ${GD}
if [ -f "${GD}.tar.gz" ]; then
 echo ${GD} has already been downloaded.
else
 wget http://www.boutell.com/gd/http/${GD}.tar.gz
fi

echo Downloading ${AMR}
if [ -f "${AMR}.tar.bz2" ]; then
 echo ${AMR} has already been downloaded.
else
 wget http://ftp.penguin.cz/pub/users/utx/amr/${AMR}.tar.bz2
fi

echo Downloading Ruby
if [ -f "${RUBY}.tar.gz" ]; then
 echo ${RUBY} has already been downloaded.
else
 wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/${RUBY}.tar.gz
fi

echo Downloading ${FLVTOOL2}
if [ -f "${FLVTOOL2}.tgz" ]; then
 echo ${FLVTOOL2} has already been downloaded.
else
 wget http://rubyforge.org/frs/download.php/9225/${FLVTOOL2}.tgz
fi

echo Downloading ${FFMPEGPHP}
if [ -f "${FFMPEGPHP}.tbz2" ]; then
 echo ${FFMPEGPHP} has already been downloaded.
else
 wget http://downloads.sourceforge.net/project/ffmpeg-php/ffmpeg-php/0.6.0/${FFMPEGPHP}.tbz2
fi

echo Downloading ${CODECS}
if [ -f "${CODECS}.tar.bz2" ]; then
 echo ${CODECS} has already been downloaded.
else
 wget http://www3.mplayerhq.hu/MPlayer/releases/codecs/${CODECS}.tar.bz2
fi

echo Checking out FFMPEG
cd ${SRCDIR}
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

echo Checking out MPlayer
cd ${SRCDIR}
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer

echo ---------- Unpacking downloaded archives. This process may take several minutes! ----------

cd ${SRCDIR}
# Unpack them all
echo Extracting ${PHP5}...
if [ -d "${PHP5}" ]; then
 echo ${PHP5} is already extracted.
else
 tar xzf ${DISTDIR}/${PHP5}.tar.gz
 echo Done.
fi

echo Extracting ${LIBICONV}...
if [ -d "${LIBICONV}" ]; then
 echo ${LIBICONV} is already extracted
else
 tar xzf ${DISTDIR}/${LIBICONV}.tar.gz
 echo Done.
fi

echo Extracting ${LIBMCRYPT}...
if [ -d "${LIBMCRYPT}" ]; then
 echo ${LIBMCRYPT} is already extracted.
else
 tar xzf ${DISTDIR}/${LIBMCRYPT}.tar.gz
 echo Done.
fi

echo Extracting ${LIBXML2}...
if [ -d "${LIBXML2}" ]; then
 echo ${LIBXML2} is already extracted.
else
 tar xzf ${DISTDIR}/${LIBXML2}.tar.gz
 echo Done.
fi

echo Extracting ${LIBXSLT}...
if [ -d "${LIBXSLT}" ]; then
 echo ${LIBXSLT} is already extracted.
else
 tar xzf ${DISTDIR}/${LIBXSLT}.tar.gz
 echo Done.
fi

echo Extracting ${MHASH}...
if [ -d "${MHASH}" ]; then
 echo ${MHASH} is already extracted.
else
 tar xzf ${DISTDIR}/${MHASH}.tar.gz
 echo Done.
fi

echo Extracting ${ZLIB}...
if [ -d "${ZLIB}" ]; then
 echo ${ZLIB} is already extracted.
else
 tar xzf ${DISTDIR}/${ZLIB}.tar.gz
 echo Done.
fi

echo Extracting ${CURL}...
if [ -d "${CURL}" ]; then
 echo ${CURL} is already extracted.
else
 tar xzf ${DISTDIR}/${CURL}.tar.gz
 echo Done.
fi

echo Extracting ${LIBIDN}...
if [ -d "${LIBIDN}" ]; then
 echo ${LIBIDN} is already extracted.
else
 tar xzf ${DISTDIR}/${LIBIDN}.tar.gz
 echo Done.
fi

echo Extracting ${CCLIENT}...
if [ -d "${CCLIENT}" ]; then
 echo ${CCLIENT} is already extracted.
else
 uncompress -cd ${DISTDIR}/${CCLIENT}.tar.Z |tar x
 echo Done.
fi

echo Extracting ${FREETYPE}...
if [ -d "${FREETYPE}" ]; then
 echo ${FREETYPE} is already extracted.
else
 tar xzf ${DISTDIR}/${FREETYPE}.tar.gz
 echo Done.
fi

echo Extracting ${OPENSSL}...
if [ -d "${OPENSSL}" ]; then
 echo ${OPENSSL} is already extracted.
else
 tar xzf ${DISTDIR}/${OPENSSL}.tar.gz
 echo Done.
fi

echo Extracting ${AUTOCONF}
if [ -d "${AUTOCONF}" ]; then
 echo ${AUTOCONF} is already extracted.
else
 tar -zxf ${DISTDIR}/${AUTOCONF}.tar.gz
 echo Done.
fi

echo Extracting ${LAME}
if [ -d "${LAME}" ]; then
 echo ${LAME} is already extracted.
else
 tar -zxvf ${DISTDIR}/${LAME}.tar.gz
 echo Done.
fi

echo Extracting ${LIBOGG}
if [ -d "${LIBOGG}" ]; then
 echo ${LIBOGG} is already extracted.
else
 tar -zxf ${DISTDIR}/${LIBOGG}.tar.gz
 echo Done.
fi

echo Extracting ${AMR}
if [ -d "${AMR}" ]; then
 echo ${AMR} is already extracted.
else
 tar -vxjf ${DISTDIR}/${AMR}.tar.bz2
 echo Done.
fi

echo Extracting ${LIBVORBIS}
if [ -d "${LIBVORBIS}" ]; then
 echo ${LIBVORBIS} is already extracted.
else
 tar -zxf ${DISTDIR}/${LIBVORBIS}.tar.gz
 echo Done.
fi

echo Extracting ${GD}
if [ -d "${GD}" ]; then
 echo ${GD} is already extracted.
else
 tar -zxf ${DISTDIR}/${GD}.tar.gz
 echo Done.
fi

echo Extracting Ruby
if [ -d "${RUBY}" ]; then
 echo Ruby is already extracted.
else
 tar -xvf ${DISTDIR}/${RUBY}.tar.gz
 echo Done.
fi

echo Extracting ${FLVTOOL2}
if [ -d "${FLVTOOL2}" ]; then
 echo ${FLVTOOL2} is already extracted.
else
 tar -zxvf ${DISTDIR}/${FLVTOOL2}.tgz
 echo Done.
fi

echo Extracting ${FFMPEGPHP}
if [ -d "${FFMPEGPHP}" ]; then
 echo ${FFMPEGPHP} is already extracted.
else
 tar -vxjf ${DISTDIR}/${FFMPEGPHP}.tbz2
 echo Done.
fi

echo Extracting ${CODECS}
if [ -d "${HOME}/lib/${CODECS}" ]; then
 echo ${CODECS} is already extracted.
else
 tar -vxjf ${DISTDIR}/${CODECS}.tar.bz2
 mv ${CODECS} $HOME/lib
 echo Done.
fi

echo
echo ---------- Building Packages ----------
echo
# Build them in the required order to satisfy dependencies.

#libiconv
echo
echo ---------- ${LIBICONV} ----------
echo
cd ${SRCDIR}/${LIBICONV}
./configure --enable-extra-encodings --prefix=$HOME
# make clean
make
make install

#libxml2
echo
echo ---------- ${LIBXML2} ----------
echo
cd ${SRCDIR}/${LIBXML2}
./configure --with-iconv=$HOME --prefix=$HOME
# make clean
make
make install

#libxslt
echo
echo ---------- ${LIBXSLT} ----------
echo
cd ${SRCDIR}/${LIBXSLT}
./configure --prefix=$HOME
 --with-libxml-prefix=$HOME
 --with-libxml-include-prefix=$HOME/include/
 --with-libxml-libs-prefix=$HOME/lib/
# make clean
make
make install

#zlib
echo
echo ---------- ${ZLIB} ----------
echo
cd ${SRCDIR}/${ZLIB}
./configure --shared --prefix=$HOME
# make clean
make
make install

#libmcrypt
echo
echo ---------- ${LIBMCRYPT} ----------
echo
cd ${SRCDIR}/${LIBMCRYPT}
./configure --disable-posix-threads --prefix=$HOME
# make clean
make
make install

#libmcrypt lltdl issue!!
echo
echo ---------- ${LIBMCRYPT}/libltdl ----------
echo
cd  ${SRCDIR}/${LIBMCRYPT}/libltdl
./configure --prefix=$HOME --enable-ltdl-install
# make clean
make
make install

#mhash
echo
echo ---------- ${MHASH} ----------
echo
cd ${SRCDIR}/${MHASH}
./configure --prefix=$HOME
# make clean
make
make install

#freetype
echo
echo ---------- ${FREETYPE} ----------
echo
cd ${SRCDIR}/${FREETYPE}
./configure --prefix=$HOME
# make clean
make
make install

#libidn
echo
echo ---------- ${LIBIDN} ----------
echo
cd ${SRCDIR}/${LIBIDN}
./configure --with-iconv-prefix=$HOME --prefix=$HOME
# make clean
make
make install

#cURL
echo
echo ---------- ${CURL} ----------
echo
cd ${SRCDIR}/${CURL}
./configure --with-ssl=$HOME --with-zlib=$HOME
 --with-libidn=$HOME --enable-ipv6 --enable-cookies
 --enable-crypto-auth --prefix=$HOME
# make clean
make
make install

# c-client
echo
echo ---------- ${CCLIENT_DIR} ----------
echo
cd ${SRCDIR}/${CCLIENT_DIR}
make -i ldb SSLTYPE=none
# Install targets are for wusses!
cp c-client/c-client.a $HOME/lib/libc-client.a
cp c-client/*.h $HOME/include

#OpenSSL
echo
echo ---------- ${OPENSSL} ----------
echo
cd ${SRCDIR}/${OPENSSL}
./config "--prefix=$HOME" "--openssldir=$HOME"
make
make install

#Autoconf
echo
echo ---------- ${AUTOCONF} ----------
echo
cd ${SRCDIR}/${AUTOCONF}
./configure "--prefix=$HOME"
make
make install

#Lame
echo
echo ---------- ${LAME} ----------
echo
cd ${SRCDIR}/${LAME}
./configure "--prefix=$HOME" "--enable-shared"
make
make install

#LibOgg
echo
echo ---------- ${LIBOGG} ----------
echo
cd ${SRCDIR}/${LIBOGG}
./configure --prefix=$HOME
make
make install

#OggVorbis
echo
echo ---------- ${LIBVORBIS} ----------
echo
cd ${SRCDIR}/${LIBVORBIS}
./configure "--prefix=$HOME"
make
make install

#AMR
echo
echo ---------- ${AMR} ----------
echo
cd ${SRCDIR}/${AMR}
./configure --prefix=$HOME
make && make install

#FFMPEG
echo
echo ---------- FFMPEG ----------
echo
cd ${SRCDIR}/ffmpeg
./configure --prefix=$HOME --enable-cross-compile --enable-shared --enable-libmp3lame --extra-cflags=-I$HOME/include --extra-ldflags=-L$HOME/lib
make
make install

#GD
echo
echo ---------- ${GD} ----------
echo
echo Compiling ${GD}
cd ${SRCDIR}/${GD}
./configure --prefix=$HOME
make
make install

#MPlayer
echo
echo ---------- MPlayer ----------
echo
echo Compiling MPlayer
cd ${SRCDIR}/mplayer
./configure --prefix=$HOME --codecsdir=$HOME/lib/${CODECS}
make
make install

#Ruby
echo
echo ---------- ${RUBY} ----------
echo
cd ${SRCDIR}/${RUBY}
./configure --prefix=$HOME  --exec-prefix=$HOME
make
install

#FlvTool
echo
echo ---------- ${FLVTOOL2} ----------
echo
cd ${SRCDIR}/${FLVTOOL2}
ruby setup.rb config -–prefix=$HOME --installdirs=home
ruby setup.rb setup
ruby setup.rb install

#PHP 5
echo
echo ---------- ${PHP5} ----------
echo
cd ${SRCDIR}/${PHP5}
./configure ${PHPFEATURES}
# make clean
make
make install

#copy config file
mkdir -p $HOME/etc/php5/${DOMAIN}
cp ${SRCDIR}/${PHP5}/php.ini-dist $HOME/etc/php5/${DOMAIN}/php.ini
#vi $HOME/etc/php5/${DOMAIN}/php.ini (add extension=$HOME/lib/ffmpeg.so)
cp $HOME/lib/php/extensions/no-debug-non-zts-20020429/ffmpeg.so $HOME/lib

#copy PHP CGI
mkdir -p ${HOME}/${DOMAIN}/cgi-bin
chmod 0755 ${HOME}/${DOMAIN}/cgi-bin
cp $HOME/bin/php ${HOME}/${DOMAIN}/cgi-bin/php.cgi

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/lib
export LIBRARY_PATH=$HOME/lib:$LIBRARY_PATH
export CPATH=$HOME/include/:$HOME/include/lame/

#FFMPEG-PHP
echo
echo ---------- ${FFMPEGPHP} ----------
echo
cd ${SRCDIR}/${FFMPEGPHP}
~/bin/phpize
CPPFLAGS=-I$HOME/include
./configure "--prefix=$HOME" "--libdir=$HOME/lib" "--bindir=$HOME/bin" "--with-ffmpeg=$HOME" --with-php-config=$HOME/bin/php-config
make clean
make install

echo ---------- INSTALL COMPLETE! ----------
This entry was posted in Howtus. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Trackback

  1. By Week 147 on February 19, 2010 at 8:01 pm

    [...] « Installing FFMPEG-PHP on Dreamhost PS Chipmunk and openFrameworks » [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>