Heim  >  Artikel  >  Backend-Entwicklung  >  在虚拟主机上复制安装本机Pear_PHP教程

在虚拟主机上复制安装本机Pear_PHP教程

WBOY
WBOYOriginal
2016-07-13 17:36:45814Durchsuche

在国内租来的虚拟主机上,有部分主机本身就提供了pear类库,但是不用指望它们会给你升级或安装需要的pear包.在这种情况下,可以尝试在自己的虚拟主机下安装一份pear.

通过ssh安装pear
国内绝大部分虚拟主机都不提供ssh,但若是朋友的服务器,可能会比较放宽一点给你权限.下面看看通过ssh在虚拟主机上安装pear的步骤:

PEAR 1.3.5或以下:
$ pear -s -c ~/.pearrc -d doc_dir=~/pear/docs
-d ext_dir=~/pear/ext -d php_dir=~/pear/lib
-d data_dir=~/pear/data -d test_dir=~/pear/tests
-d cache_dir=~/pear/cache -d bin_dir=~/pear/bin

PEAR 1.4以上:
$ pear config-create /home/user/pear .pearrc

这样就在用户的home下建立了一个.pearrc文件

在.bashrc文件中加入
PEAR 1.3.2 或以下:
$ pear -c ~/.pearrc install Archive_Tar PEAR Console_Getopt XML_RPC
PEAR 1.3.3以上
$ pear install -o PEAR

这样就在用户的home目录下新增了一个pear目录,这份pear是完全复制主机上的pear的.

为了使用刚装上的这份pear包,需要在php代码中指定include_path
PLAIN TEXT
PHP:
ini_set(include_path,~/pear/lib. PATH_SEPARATOR
        .ini_get(include_path));
 
// From PHP 4.3.0 onward, you can use the following,
// which especially useful on shared hosts:
set_include_path(~/pear/lib. PATH_SEPARATOR
                 .get_include_path());
?>
通过ftp/ftps/sftp安装pear
通过ftp之类的向远程虚拟主机上安装pear,这无疑是个好主意.主要通过pear的程序包PEAR_RemoteInstaller来完成这功能.有几点要确定:

本机是php 5.0以上
如果需要用ftps安装,那么本机的php需要增加openssl extension
如果需要用ssh安装,那么本机的php需要增加ssh2 extension
php目录的pear命令行可执行
ftp有写权限
因为时间关系,暂时不写具体步骤了,有需要的朋友可以参考下面的链接.

参考文档:
pear manual

作者:volcano发表于9月 15, 2006 at 8:40 am

版权信息:可以任意转载, 转载时请务必以超链接形式标明文章原始出处和作者信息及此声明

永久链接 - http://www.ooso.net/index.php/archives/241

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/486638.htmlTechArticle在国内租来的虚拟主机上,有部分主机本身就提供了pear类库,但是不用指望它们会给你升级或安装需要的pear包.在这种情况下,可以尝试在自己...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn