motivation
To run an OpenID consumer library, e.g. JanRain’s PHP lib and Pádraic Brady’s pear lib, on Dreamhost
intended audience
Anyone familiar with:
- Command-line build
- shell scripting
- running PHP as CGI process
references
- Dreamhost’s wiki page on the subject
- The LegHumped blog post, “Idiots Guide to Installing PHP“
- The Rotacoo post on “How-to set up OpenID for WordPress“, which links to a Dreamhost forum discussion of the topic
notes
- I broke the basic script into 3 pieces: getting, unpacking, and installing. This way we can re-install a package without re-getting the source code it or re-building it.
- The syntax highlighting on WordPress does not support shell scripting, so it’s a bit off, but it helps
- The scripts presented here were used to successfully get, build, and install PHP5, but I have not yet stopped to figure out how to run it, so there may be a huge, as-yet-unknown bug looming in the near future, but for now I’m riding high from the successful build and RUN – it works too! 🙂
- This build configuration results in the following (non-fatal) error message:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Building in NON-COMPLIANCE with RFC 3501 security requirements:
+ Non-compliant:
++ TLS/SSL encryption is NOT supported
++ Unencrypted plaintext passwords are permitted
+
+ In order to rectify this problem, you MUST build with:
++ SSLTYPE=nopwd
+ You must also have OpenSSL or equivalent installed.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++I haven’t sorted this out yet, so please post a comment if your familiar with what this is about.
script
#!/bin/sh #part 1: get the source code set -e # build dir SRCDIR=${HOME}/src PHP5="php-5.2.5" LIBICONV="libiconv-1.11" LIBMCRYPT="libmcrypt-2.5.7" LIBXML2="libxml2-2.6.32" LIBXSLT="libxslt-1.1.24" MHASH="mhash-0.9.7.1" ZLIB="zlib-1.2.3" CURL="curl-7.14.0" LIBIDN="libidn-0.6.8" CCLIENT="imap-2004g" CCLIENT_DIR="imap-2004g" # Another pest! FREETYPE="freetype-2.2.1" OPENSSL="openssl-0.9.8i" GMP="gmp-4.2.4" # Pre-download clean up!!!! rm -rf $SRCDIR mkdir -p ${SRCDIR} cd ${SRCDIR} # Get all the required packages echo "Wgetting ..." wget -c http://us.php.net/get/${PHP5}.tar.gz/from/this/mirror wget -c "http://mirrors.usc.edu/pub/gnu/libiconv/${LIBICONV}.tar.gz wget -c http://easynews.dl.sourceforge.net/sourceforge/mcrypt/${LIBMCRYPT}.tar.gz wget -c ftp://xmlsoft.org/libxml2/${LIBXML2}.tar.gz wget -c ftp://xmlsoft.org/libxml2/${LIBXSLT}.tar.gz wget -c http://superb-west.dl.sourceforge.net/sourceforge/mhash/${MHASH}.tar.gz wget -c http://www.zlib.net/${ZLIB}.tar.gz wget -c http://curl.haxx.se/download/${CURL}.tar.gz wget -c http://kent.dl.sourceforge.net/sourceforge/freetype/${FREETYPE}.tar.gz wget -c ftp://alpha.gnu.org/pub/gnu/libidn/${LIBIDN}.tar.gz wget -c ftp://ftp.cac.washington.edu/imap/old/${CCLIENT}.tar.Z wget -c http://www.openssl.org/source/${OPENSSL}.tar.gz wget -c http://www.openssl.org/source/${OPENSSL}.tar.gz wget -c ftp://ftp.gnu.org/gnu/gmp/${GMP}.tar.gz echo "Done!"
#!/bin/sh #part 2: unpack set -e # build dir SRCDIR=${HOME}/src LIBDIR=${HOME}/lib # Update version information here. PHP5="php-5.2.5" LIBICONV="libiconv-1.11" LIBMCRYPT="libmcrypt-2.5.7" LIBXML2="libxml2-2.6.32" LIBXSLT="libxslt-1.1.24" MHASH="mhash-0.9.7.1" ZLIB="zlib-1.2.3" CURL="curl-7.14.0" LIBIDN="libidn-0.6.8" CCLIENT="imap-2004g" CCLIENT_DIR="imap-2004g" # Another pest! FREETYPE="freetype-2.2.1" OPENSSL="openssl-0.9.8i" GMP="gmp-4.2.4" # Pre-unpack clean up function cleanup(){ echo "removing ${LIBDIR}/${1}" rm -rf $LIBDIR/$1 mkdir -p $LIBDIR/$PHP5 echo Done. } #note: rename imap-2004g.tar.Z to imap-2004g.tar.gz in advance function unpack(){ echo Extracting $1 cp $SRCDIR/$1.tar.gz $1.tar.gz tar xzf $1.tar.gz rm $1.tar.gz echo Done. } echo "Cleaning up ... " cleanup $PHP5 cleanup $LIBICONV cleanup $LIBMCRYPT cleanup $LIBXML2 cleanup $LIBXSLT cleanup $MHASH cleanup $ZLIB cleanup $CURL cleanup $LIBIDN cleanup $CCLIENT cleanup $CCLIENT_DIR cleanup $FREETYPE cleanup $OPENSSL cleanup $GMP echo "Unpacking ... " cd $LIBDIR unpack ${PHP5} unpack $LIBICONV unpack $LIBMCRYPT unpack $LIBXML2 unpack $LIBXSLT unpack $MHASH unpack $ZLIB unpack $CURL unpack $LIBIDN unpack $CCLIENT unpack $CCLIENT_DIR unpack $FREETYPE unpack $OPENSSL unpack $GMP echo "Done!"
#!/bin/sh #part 3: install set -e # build dir SRCDIR=${HOME}/src INSTALLDIR=${HOME}/bin DOMAIN="example.com" LIBDIR=${HOME}/lib # Update version information here. PHP5="php-5.2.5" LIBICONV="libiconv-1.11" LIBMCRYPT="libmcrypt-2.5.7" LIBXML2="libxml2-2.6.32" LIBXSLT="libxslt-1.1.24" MHASH="mhash-0.9.7.1" ZLIB="zlib-1.2.3" CURL="curl-7.14.0" LIBIDN="libidn-0.6.8" CCLIENT="imap-2004g" CCLIENT_DIR="imap-2004g" # Another pest! FREETYPE="freetype-2.2.1" OPENSSL="openssl-0.9.8i" GMP="gmp-4.2.4" # What PHP features do you want enabled? PHPFEATURES="--prefix=${INSTALLDIR}/php5 \ --with-config-file-path=${INSTALLDIR}/conf/php5/${DOMAIN} \ --enable-fastcgi \ --enable-force-cgi-redirect \ --with-xml \ --with-libxml-dir=${INSTALLDIR} \ --with-freetype-dir=${INSTALLDIR} \ --enable-soap \ --with-openssl=${INSTALLDIR} \ --with-mhash=${INSTALLDIR} \ --with-mcrypt=${INSTALLDIR} \ --with-zlib-dir=${INSTALLDIR} \ --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=${INSTALLDIR} \ --enable-sqlite-utf8 \ --enable-calendar \ --with-curl=${INSTALLDIR} \ --enable-mbstring \ --enable-mbregex \ --enable-bcmath \ --with-mysql=/usr \ --with-mysqli \ --with-pear \ --with-gettext \ --with-imap=${INSTALLDIR} \ --without-imap-ssl \ --with-gmp={INSTALLDIR}" #the --with-gmp flag is important to avoid this error: #"GNU MP Library version 4.1.2 or greater required." #See http://leghumped.com/php_inst.sh #& DH forum http://discussion.dreamhost.com/showflat.pl?Cat=&Board=forum_programming&Number=78146 echo "Installing ..." #libiconv cd ${LIBDIR}/${LIBICONV} ./configure --enable-extra-encodings --prefix=${INSTALLDIR} # make clean make make install #libxml2 cd ${LIBDIR}/${LIBXML2} ./configure --with-iconv=${INSTALLDIR} --prefix=${INSTALLDIR} # make clean make make install #libxslt cd ${LIBDIR}/${LIBXSLT} ./configure --prefix=${INSTALLDIR} \ --with-libxml-prefix=${INSTALLDIR} \ --with-libxml-include-prefix=${INSTALLDIR}/include/ \ --with-libxml-libs-prefix=${INSTALLDIR}/lib/ # make clean make make install #zlib cd ${LIBDIR}/${ZLIB} ./configure --shared --prefix=${INSTALLDIR} # make clean make make install #libmcrypt cd ${LIBDIR}/${LIBMCRYPT} ./configure --disable-posix-threads --prefix=${INSTALLDIR} # make clean make make install #libmcrypt lltdl issue!! cd ${LIBDIR}/${LIBMCRYPT}/libltdl ./configure --prefix=${INSTALLDIR} --enable-ltdl-install # make clean make make install #mhash cd ${LIBDIR}/${MHASH} ./configure --prefix=${INSTALLDIR} # make clean make make install #freetype cd ${LIBDIR}/${FREETYPE} ./configure --prefix=${INSTALLDIR} # make clean make make install #libidn cd ${LIBDIR}/${LIBIDN} ./configure --with-iconv-prefix=${INSTALLDIR} --prefix=${INSTALLDIR} # make clean make make install #cURL cd ${LIBDIR}/${CURL} ./configure --with-ssl=${INSTALLDIR} --with-zlib=${INSTALLDIR} \ --with-libidn=${INSTALLDIR} --enable-ipv6 --enable-cookies \ --enable-crypto-auth --prefix=${INSTALLDIR} # make clean make make install # c-client cd ${LIBDIR}/${CCLIENT_DIR} make -i ldb SSLTYPE=none # Install targets are for wusses! cp c-client/c-client.a ${INSTALLDIR}/lib/libc-client.a cp c-client/*.h ${INSTALLDIR}/include #OpenSSL cd ${LIBDIR}/${OPENSSL} ./config --prefix=${INSTALLDIR} --openssldir=${INSTALLDIR} make make install # gmp cd ${LIBDIR}/${GMP} #--prefix=${INSTALLDIR} --libdir=${INSTALLDIR}/lib req'd to avoid error: #"configure: error: Unable to locate gmp.h" #credit: http://leghumped.com/php_inst.sh ./configure --prefix=${INSTALLDIR} --libdir=${INSTALLDIR}/lib # make clean make make install #PHP 5 cd ${LIBDIR}/${PHP5} LDFLAGS="-L${INSTALLDIR}" ./configure ${PHPFEATURES} # make clean make make install #copy config file mkdir -p ${HOME}/conf/php5/${DOMAIN} cp ${LIBDIR}/${PHP5}/php.ini-dist ${HOME}/conf/php5/${DOMAIN}/php.ini #copy PHP CGI mkdir -p ${HOME}/${DOMAIN}/cgi-bin chmod 0755 ${HOME}/${DOMAIN}/cgi-bin cp ${INSTALLDIR}/php5 ${HOME}/${DOMAIN}/cgi-bin/php5.cgi echo "Done!"
After obtaining and unpacking the requisite files and compiling PHP, tell Apache where to find PHP by putting the following in an .htaccess file located in your domain’s root directory (credit: LegHumped):
Options +ExecCGI AddHandler php-cgi .php Action php-cgi /cgi-bin/php.cgi
Good luck!!!
“noting the code used is a variation of the Dreamhost script”… almost sounds like you’re accusing me of plagiarism. I did state that in the post, and it was still a pain to get it working. 😉
Hi Echilon,
No accusation was intended. I am grateful for your work. I only made the note to assist other folks (like me) in being aware of the various solutions to this problem. I’ll change my wording to more accurately convey my intent.
Question with libxml2 I am having troubles getting it to work on dreamhost did you run into any problems installing libxml2? I get this error ->
In file included from /usr/include/netinet/in.h:365,
from /usr/include/netdb.h:28,
from nanohttp.c:40:
/usr/include/bits/byteswap.h:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘package’
/usr/include/bits/byteswap.h:1: error: missing terminating ‘ character
/usr/include/bits/byteswap.h:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘can’
/usr/include/bits/byteswap.h:20: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘version’
/usr/include/bits/byteswap.h:26: error: stray ‘`’ in program
/usr/include/bits/byteswap.h:26: error: missing terminating ‘ character
/usr/include/bits/byteswap.h:27: error: stray ‘`’ in program
/usr/include/bits/byteswap.h:27: error: missing terminating ‘ character
nanohttp.c: In function ‘xmlNanoHTTPConnectHost’:
nanohttp.c:1017: warning: implicit declaration of function ‘__bswap_16’
nanohttp.c:1017: warning: nested extern declaration of ‘__bswap_16′
make[2]: *** [nanohttp.lo] Error 1
make[2]: Leaving directory `/home/222222/source/libxml2-2.6.32′
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/222222/source/libxml2-2.6.32’
make: *** [all] Error 2
Yikes. I haven’t worked with this stuff in a while, and am no longer on dreamhost, so I don’t think I’ll be able to be of much help. I do not remember receiving an error regarding libxml2. The only error I got was the SSL one I noted.
If you wouldn’t mind, when you do come across a solution, please post an explanation or a link to one, for the benefit of the readers who come after.
Thanks and good luck.