定制安装PHP5.2.0和PDFlib7.0.2到Dreamhost主机

作者:


最后更新于 | 最初发布于 | 分类:


为了使用PDFlib扩展,就必须自己定制安装PHP,而不能使用Dreamhost默认安装的PHP5和PHP4。
下面介绍一下我安装的过程。

1)复制接下来这段PHP 5.2.0 安装script,记得把中间第十四行,your.domain.com这个部分用你的域名来代替。

2)登陆到SSH,创建一个新文件叫做installscript。

3)打开installscript,并且把上面修改好的安装script复制进去,保存后退出。

4)给这个文件可执行权限:
chmod +x installscript
5)然后执行这个文件:
./installscript
6)在网站域名目录下,新建一个.htaccess文件,内容是:
AddHandler phpFive .php
Action phpFive /cgi-bin/php.cgi

这时你自己的PHP5就安装好了,你可以看到这样一些文件:
/home/YOUR USERNAME/YOUR DOMAIN HERE/.htaccess
/home/YOUR USERNAME/YOUR DOMAIN HERE/cgi-bin/php.cgi

接下来是安装PDFlib 7.0.2
1)下载并解开安装压缩包
wget https://www.pdflib.com/binaries/PDFlib/702/PDFlib-7.0.2-Linux-php.tar.gz
tar -xvvzf PDFlib-7.0.2-Linux-php.tar.gz
2)复制PDFlib到你的域名下的cgi-bin目录
cp ../../PDFlib-7.0.2-Linux-php/bind/php5/php-520/libpdf_php.so .
3)复制php.ini到cgi-bin
cp ../../php5/etc/php5/YOUR DOMAIN HERE/php.ini .
4)打开php.ini确认扩展目录的设置是这样的:
extension_dir = "./"
5)添加PDFlib的扩展设置:
extension=libpdf_php.so

保存后退出,现在可以在域名目录下用phpinfo()函数来验证安装是否正确了。

PHP5安装script

#!/bin/sh

# Script updated 2006-12-25 by Carl McDade (hiveminds.co.uk) to allow memory limit and freetype
#
# Script updated 2007-11-24 by Andrew (ajmconsulting.net) to allow 3rd wget line to pass
# 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="your.domain.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

# And where should it be installed?
INSTALLDIR=${HOME}/php5

# 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

# Update version information here.
PHP5="php-5.2.0"
LIBICONV="libiconv-1.11"
LIBMCRYPT="libmcrypt-2.5.7"
LIBXML2="libxml2-2.6.27"
LIBXSLT="libxslt-1.1.18"
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"

# What PHP features do you want enabled?
PHPFEATURES="--prefix=${INSTALLDIR} \
--with-config-file-path=${INSTALLDIR}/etc/php5/${DOMAIN} \
--enable-fastcgi \
--enable-force-cgi-redirect \
--with-xml \
--with-libxml-dir=${INSTALLDIR} \
--with-freetype-dir=${INSTALLDIR} \
--enable-soap \
--with-openssl=/usr \
--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 \
--with-mysql=/usr \
--with-mysqli \
--without-pear \
--with-gettext \
--with-imap=${INSTALLDIR} \
--with-imap-ssl=/usr"

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

# Push the install dir's bin directory into the path
export PATH=${INSTALLDIR}/bin:$PATH

#setup directories
mkdir -p ${SRCDIR}
mkdir -p ${INSTALLDIR}
mkdir -p ${DISTDIR}
cd ${DISTDIR}

# Get all the required packages
wget -c https://us.php.net/distributions/${PHP5}.tar.gz
wget -c https://mirrors.usc.edu/pub/gnu/libiconv/${LIBICONV}.tar.gz
wget -c https://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 https://superb-west.dl.sourceforge.net/sourceforge/mhash/${MHASH}.tar.gz
wget -c https://www.zlib.net/${ZLIB}.tar.gz
wget -c https://curl.haxx.se/download/${CURL}.tar.gz
wget -c https://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

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

cd ${SRCDIR}
# Unpack them all
echo Extracting ${PHP5}...
tar xzf ${DISTDIR}/${PHP5}.tar.gz
echo Done.
echo Extracting ${LIBICONV}...
tar xzf ${DISTDIR}/${LIBICONV}.tar.gz
echo Done.
echo Extracting ${LIBMCRYPT}...
tar xzf ${DISTDIR}/${LIBMCRYPT}.tar.gz
echo Done.
echo Extracting ${LIBXML2}...
tar xzf ${DISTDIR}/${LIBXML2}.tar.gz
echo Done.
echo Extracting ${LIBXSLT}...
tar xzf ${DISTDIR}/${LIBXSLT}.tar.gz
echo Done.
echo Extracting ${MHASH}...
tar xzf ${DISTDIR}/${MHASH}.tar.gz
echo Done.
echo Extracting ${ZLIB}...
tar xzf ${DISTDIR}/${ZLIB}.tar.gz
echo Done.
echo Extracting ${CURL}...
tar xzf ${DISTDIR}/${CURL}.tar.gz
echo Done.
echo Extracting ${LIBIDN}...
tar xzf ${DISTDIR}/${LIBIDN}.tar.gz
echo Done.
echo Extracting ${CCLIENT}...
uncompress -cd ${DISTDIR}/${CCLIENT}.tar.Z |tar x
echo Done.
echo Extracting ${FREETYPE}...
tar xzf ${DISTDIR}/${FREETYPE}.tar.gz
echo Done.

# Build them in the required order to satisfy dependencies.

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

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

#libxslt
cd ${SRCDIR}/${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 ${SRCDIR}/${ZLIB}
./configure --shared --prefix=${INSTALLDIR}
# make clean
make
make install

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

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

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

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

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

#cURL
cd ${SRCDIR}/${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 ${SRCDIR}/${CCLIENT_DIR}
make ldb
# Install targets are for wusses!
cp c-client/c-client.a ${INSTALLDIR}/lib/libc-client.a
cp c-client/*.h ${INSTALLDIR}/include

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

#copy config file
mkdir -p ${INSTALLDIR}/etc/php5/${DOMAIN}
cp ${SRCDIR}/${PHP5}/php.ini-dist ${INSTALLDIR}/etc/php5/${DOMAIN}/php.ini

#copy PHP CGI
mkdir -p ${HOME}/${DOMAIN}/cgi-bin
chmod 0755 ${HOME}/${DOMAIN}/cgi-bin
cp ${INSTALLDIR}/bin/php ${HOME}/${DOMAIN}/cgi-bin/php.cgi
rm -rf $SRCDIR $DISTDIR
echo ---------- INSTALL COMPLETE! ----------

参考文章:
PHP 5 install script
安装PDFlib





关于作者
搜索
归档

Online Tools

Code Convertor