techsir 登陆 |注册|TS首页
  首页 快活林 猿氏悟语

DreamHost自己编译PHP,支持采集(allow_url_fopen)

By: 东方不摆 发表于 2008-9-30 12:08:50 · 11784次点击   回复:0   
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. 修改文件属性为可执行,并执行
  1. chmod +x php5_update.sh
  2. ./php5_update.sh
复制代码
5. 增加定时项,每周执行一次 php5_update.sh
  1. crontab -e
复制代码
然后输入内容
  1. @weekly /home/your-user-name/your-domain-name/php5-update.sh
复制代码
按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 中添加如下内容:
  1. AddHandler phpFive .php
  2. Action phpFive /cgi-bin/php.cgi
复制代码
6. 修改 php.ini,该文件在 ~/your_domain_name/etc/php5/ 目录下,打开 allow_url_fileopen 选项
installscript.sh源码:
  1. #!/bin/sh
  2. # Script updated 2006-12-25 by Carl McDade (hiveminds.co.uk) to allow memory limit and freetype
  3. # Save the code to a file as *.sh
  4. # Abort on any errors
  5. set -e

  6. # The domain in which to install the PHP CGI script.
  7. export DOMAIN=”your.domain.com”

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

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

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

  18. # Pre-download clean up!!!!
  19. rm -fr $SRCDIR $DISTDIR

  20. # Update version information here.
  21. PHP5=”php-5.2.0″
  22. LIBICONV=”libiconv-1.11″
  23. LIBMCRYPT=”libmcrypt-2.5.7″
  24. LIBXML2=”libxml2-2.6.27″
  25. LIBXSLT=”libxslt-1.1.18″
  26. MHASH=”mhash-0.9.7.1″
  27. ZLIB=”zlib-1.2.3″
  28. CURL=”curl-7.14.0″
  29. LIBIDN=”libidn-0.6.8″
  30. CCLIENT=”imap-2004g”
  31. CCLIENT_DIR=”imap-2004g” # Another pest!
  32. FREETYPE=”freetype-2.2.1″

  33. # What PHP features do you want enabled?
  34. PHPFEATURES=”–prefix=${INSTALLDIR} \
  35. –with-config-file-path=${INSTALLDIR}/etc/php5/${DOMAIN} \
  36. –enable-force-cgi-redirect \
  37. –with-xml \
  38. –with-libxml-dir=${INSTALLDIR} \
  39. –with-freetype-dir=${INSTALLDIR} \
  40. –enable-soap \
  41. –with-openssl=/usr \
  42. –with-mhash=${INSTALLDIR} \
  43. –with-mcrypt=${INSTALLDIR} \
  44. –with-zlib-dir=${INSTALLDIR} \
  45. –with-jpeg-dir=/usr \
  46. –with-png-dir=/usr \
  47. –with-gd \
  48. –enable-gd-native-ttf \
  49. –enable-memory-limit
  50. –enable-ftp \
  51. –with-exif \
  52. –enable-sockets \
  53. –enable-wddx \
  54. –with-iconv=${INSTALLDIR} \
  55. –enable-sqlite-utf8 \
  56. –enable-calendar \
  57. –with-curl=${INSTALLDIR} \
  58. –enable-mbstring \
  59. –enable-mbregex \
  60. –with-mysql=/usr \
  61. –with-mysqli \
  62. –without-pear \
  63. –with-gettext \
  64. –with-imap=${INSTALLDIR} \
  65. –with-imap-ssl=/usr”

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

  67. # Push the install dir’s bin directory into the path
  68. export PATH=${INSTALLDIR}/bin:$PATH

  69. #setup directories
  70. mkdir -p ${SRCDIR}
  71. mkdir -p ${INSTALLDIR}
  72. mkdir -p ${DISTDIR}
  73. cd ${DISTDIR}

  74. # Get all the required packages
  75. wget -c [url]http://us3.php.net/distributions/[/url]${PHP5}.tar.gz
  76. wget -c [url]http://mirrors.usc.edu/pub/gnu/libiconv/[/url]${LIBICONV}.tar.gz
  77. wget -c [url]http://easynews.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.7.tar.gz[/url]
  78. wget -c [url]ftp://xmlsoft.org/libxml2/[/url]${LIBXML2}.tar.gz
  79. wget -c [url]ftp://xmlsoft.org/libxml2/[/url]${LIBXSLT}.tar.gz
  80. wget -c [url]http://superb-west.dl.sourceforge.net/sourceforge/mhash/[/url]${MHASH}.tar.gz
  81. wget -c [url]http://www.zlib.net/[/url]${ZLIB}.tar.gz
  82. wget -c [url]http://curl.haxx.se/download/[/url]${CURL}.tar.gz
  83. wget -c [url]http://kent.dl.sourceforge.net/sourceforge/freetype/[/url]${FREETYPE}.tar.gz
  84. wget -c [url]ftp://alpha.gnu.org/pub/gnu/libidn/[/url]${LIBIDN}.tar.gz
  85. wget -c [url]ftp://ftp.cac.washington.edu/imap/old/[/url]${CCLIENT}.tar.Z

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

  87. cd ${SRCDIR}
  88. # Unpack them all
  89. echo Extracting ${PHP5}…
  90. tar xzf ${DISTDIR}/${PHP5}.tar.gz
  91. echo Done.
  92. echo Extracting ${LIBICONV}…
  93. tar xzf ${DISTDIR}/${LIBICONV}.tar.gz
  94. echo Done.
  95. echo Extracting ${LIBMCRYPT}…
  96. tar xzf ${DISTDIR}/${LIBMCRYPT}.tar.gz
  97. echo Done.
  98. echo Extracting ${LIBXML2}…
  99. tar xzf ${DISTDIR}/${LIBXML2}.tar.gz
  100. echo Done.
  101. echo Extracting ${LIBXSLT}…
  102. tar xzf ${DISTDIR}/${LIBXSLT}.tar.gz
  103. echo Done.
  104. echo Extracting ${MHASH}…
  105. tar xzf ${DISTDIR}/${MHASH}.tar.gz
  106. echo Done.
  107. echo Extracting ${ZLIB}…
  108. tar xzf ${DISTDIR}/${ZLIB}.tar.gz
  109. echo Done.
  110. echo Extracting ${CURL}…
  111. tar xzf ${DISTDIR}/${CURL}.tar.gz
  112. echo Done.
  113. echo Extracting ${LIBIDN}…
  114. tar xzf ${DISTDIR}/${LIBIDN}.tar.gz
  115. echo Done.
  116. echo Extracting ${CCLIENT}…
  117. uncompress -cd ${DISTDIR}/${CCLIENT}.tar.Z |tar x
  118. echo Done.
  119. echo Extracting ${FREETYPE}…
  120. tar xzf ${DISTDIR}/${FREETYPE}.tar.gz
  121. echo Done.

  122. # Build them in the required order to satisfy dependencies.

  123. #libiconv
  124. cd ${SRCDIR}/${LIBICONV}
  125. ./configure –enable-extra-encodings –prefix=${INSTALLDIR}
  126. # make clean
  127. make
  128. make install

  129. #libxml2
  130. cd ${SRCDIR}/${LIBXML2}
  131. ./configure –with-iconv=${INSTALLDIR} –prefix=${INSTALLDIR}
  132. # make clean
  133. make
  134. make install

  135. #libxslt
  136. cd ${SRCDIR}/${LIBXSLT}
  137. ./configure –prefix=${INSTALLDIR} \
  138. –with-libxml-prefix=${INSTALLDIR} \
  139. –with-libxml-include-prefix=${INSTALLDIR}/include/ \
  140. –with-libxml-libs-prefix=${INSTALLDIR}/lib/
  141. # make clean
  142. make
  143. make install

  144. #zlib
  145. cd ${SRCDIR}/${ZLIB}
  146. ./configure –shared –prefix=${INSTALLDIR}
  147. # make clean
  148. make
  149. make install

  150. #libmcrypt
  151. cd ${SRCDIR}/${LIBMCRYPT}
  152. ./configure –disable-posix-threads –prefix=${INSTALLDIR}
  153. # make clean
  154. make
  155. make install

  156. #libmcrypt lltdl issue!!
  157. cd ${SRCDIR}/${LIBMCRYPT}/libltdl
  158. ./configure –prefix=${INSTALLDIR} –enable-ltdl-install
  159. # make clean
  160. make
  161. make install

  162. #mhash
  163. cd ${SRCDIR}/${MHASH}
  164. ./configure –prefix=${INSTALLDIR}
  165. # make clean
  166. make
  167. make install

  168. #freetype
  169. cd ${SRCDIR}/${FREETYPE}
  170. ./configure –prefix=${INSTALLDIR}
  171. # make clean
  172. make
  173. make install

  174. #libidn
  175. cd ${SRCDIR}/${LIBIDN}
  176. ./configure –with-iconv-prefix=${INSTALLDIR} –prefix=${INSTALLDIR}
  177. # make clean
  178. make
  179. make install

  180. #cURL
  181. cd ${SRCDIR}/${CURL}
  182. ./configure –with-ssl=${INSTALLDIR} –with-zlib=${INSTALLDIR} \
  183. –with-libidn=${INSTALLDIR} –enable-ipv6 –enable-cookies \
  184. –enable-crypto-auth –prefix=${INSTALLDIR}
  185. # make clean
  186. make
  187. make install

  188. # c-client
  189. cd ${SRCDIR}/${CCLIENT_DIR}
  190. make ldb
  191. # Install targets are for wusses!
  192. cp c-client/c-client.a ${INSTALLDIR}/lib/libc-client.a
  193. cp c-client/*.h ${INSTALLDIR}/include

  194. #PHP 5
  195. cd ${SRCDIR}/${PHP5}
  196. ./configure ${PHPFEATURES}
  197. # make clean
  198. make
  199. make install

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

  203. #copy PHP CGI
  204. mkdir -p ${HOME}/${DOMAIN}/cgi-bin
  205. chmod 0755 ${HOME}/${DOMAIN}/cgi-bin
  206. cp ${INSTALLDIR}/bin/php ${HOME}/${DOMAIN}/cgi-bin/php.cgi
  207. rm -fr $SRCDIR $DISTDIR
  208. echo ———- INSTALL COMPLETE! ———-
复制代码
参考文档:http://wiki.dreamhost.com/index.php/Installing_PHP5

注:此文转自网
11784次点击
0个回复  |  直到 2008-9-30 12:08:50
添加一条新回复
您需要登录后才可以回帖 登录 | 成为会员 新浪微博登陆

标签云|手机版|科技先生 ( 京ICP备07036130号 Powered by Discuz! X )

GMT+8, 2024-12-13 03:56