->
DreamHost 自己编译PHP,支持采集(allow_url_fopen)
第一种方法:
1. 下载 php_update.sh 。如果是PHP5,下载 php5_update.sh;如果是 PHP4,下载 php4_update。下面以php5举例。同时下载 附件中的 .htaccess 文件
更新一下:点这里下载php5_update.sh和htaccess文件,我打包好了。
2. FTP上传文件 php5_update.sh 和 .htaccess 到相应域名的根目录
3. SSH登录到Dreamhost,具体操作参见教程六:使用Dreamhost的Shell
4. 修改文件属性为可执行,并执行
[coolcode]chmod +x php5_update.sh
./php5_update.sh[/coolcode]
5. 增加定时项,每周执行一次 php5_update.sh
[coolcode]crontab -e[/coolcode]
然后输入内容
[coolcode]@weekly /home/your-user-name/your-domain-name/php5-update.sh[/coolcode]
按Ctrl + O保存后,按Ctrl + X退出
众所周知,DH默认是不支持大部分的采集器,因为DH默认PHP的 allow_url_fopen 选项没有打开,这是DH的一个大缺陷。好在DH可以让用户自己编译PHP,打开这些选项。
编译方法:
1. 下载附件中的文件 installscript.sh,将其中的“your.domain.com”替换为你的真实域名,然后上传到你的域名目录中
2. 用shell登陆系统
3. 修改 installscript.sh 的属性为可执行:执行命令 “chmod +x installscript.sh”
4. 执行installscript.sh: ./installscript
5. 编译成功后,修改 .htaccess,使用刚才编译出的php程序来解析php文件;在 .htaccess 中添加如下内容:
[coolcode]AddHandler phpFive .php
Action phpFive /cgi-bin/php.cgi[/coolcode]
6. 修改 php.ini,该文件在 ~/your_domain_name/etc/php5/ 目录下,打开 allow_url_fileopen 选项
installscript.sh源码:
[coolcode]#!/bin/sh
# Script updated 2006-12-25 by Carl McDade (hiveminds.co.uk) to allow memory limit and freetype
# 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 -fr $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-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 \
–with-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 http://us3.php.net/distributions/${PHP5}.tar.gz
wget -c http://mirrors.usc.edu/pub/gnu/libiconv/${LIBICONV}.tar.gz
wget -c http://easynews.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.7.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
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 -fr $SRCDIR $DISTDIR
echo ———- INSTALL COMPLETE! ———-[/coolcode]
参考文档:http://wiki.dreamhost.com/index.php/Installing_PHP5
注:此文转自网络。
版权声明
作者:dupola原文标题:[转]DreamHost自己编译PHP,支持采集(allow_url_fopen)
原文链接:http://dupola.com/post/108
(C) dupola 版权所有,转载时必须以链接形式注明作者和原始出处及本声明。
19 条评论了已经
Trackbacks/Pingbacks
发表评论
字体为 粗体 是必填项目,邮箱地址 永远不会 公布。
允许部分 HTML 代码:<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
URLs(网站链接)必须完整有效 (比如: http://dupola.com),所有标签都必须完整的关闭。
超出部分系统将会自动分段及换行。
请保证评论内容是与日志或 Blog 内容相关的,灌水、攻击性或不恰当的评论 可能 会被编辑或删除。

.htaccess在哪里???!找半天也找不到
在这里。编辑原文代码就乱了。大家下载这个吧,我把phpupdate.sh等文件也放进去了。
大哥,我的站装都装不好,可不可以做个更详细的教程啊,最好是带图片的,重点放在数据库的配置上就好了。谢谢。可以加我的QQ教我么,我的QQ是632684128。
就按这个教程就可以呀。。。。。这里已经有人成功了,http://dupola.net/post/109#comment-4298
那我再试试好了,如果有问题解决不了的话我可不可以把 问题贴出来,你 给我指导一下。谢谢。
@qxhy123 好的。。。。。
我又来了,这回装上了,但是 有个问题一直解决不了,就是后台参数那里一直显示这个东西Warning: Invalid argument supplied for foreach() in /home/.nitny/ladh1034/xiaoshuocity.cn/admin/configs.php on line 110
请问如何解决呀,谢谢,我的联系方式已经留在上面了。
我想问的是
php5安装好以后
.htaccess貌似没有被创建,难道是把2行内容复制进去么
另外
~/your_domain_name/etc/php5/ 下找不到php.ini
只有在~/your_domain_name/cgi-bin/下有php.cgi
@Four php.ini 是要自己创建的。我也只是在发文章的时候测试成功了,后来再没弄过了。按照步骤,好像是某一步的时候它就自动创建了。然后你再创建一个.htaccess 文件就行了,在SSH下。
你的杰奇现在还能采集?
./php5_update.sh我执行这步不行
执行定期任务没权限
@31 我的还可以,从一开始都可以。
我想问下,为什么你挂在dreamhost的小说网站只被百度收录一页啊?
我猜可能是百度对杰奇小说程序采集的站给了特别关注。。。如果用杰奇搞原创的,应该不会只收录一页吧?如果原创的也只收录一页,那看来就是百度把杰奇封了。
@菜鸟 晕…………那你也用不着公布的这么详细吧。。。我不是有邮箱么……
很想用你的方法 可惜我看不是很明白
@toprank 多看几遍就明白啦。
谢谢 ,很不错的教程
不过这里好像有点不对 4. 执行installscript.sh: ./installscript
应该是:执行installscript.sh: ./installscript.sh
就是想问下,安装installscript.sh花了我一个多小时。。。。正常吗
@James Hui 那你开fopen 一共花了多长时间呢?我花了大概一个小时左右。