经过试验,终于调试通过了PEAR在虚拟主机的中安装.
1.将PEAR拷贝到网站的目录下,我拷贝到Library/PEAR目录中.(如果只使用DB,则拷贝PEAR.php、db.php和db目录即可.)
在PHP中声明:
//下面这几种方式都可以
ini_set("include_path", ini_get("include_path") . ".;Library/PEAR");
//ini_set("include_path", "Library/PEAR");
//set_include_path(get_include_path().';'.'Library/PEAR');
//set_include_path("Library/PEAR");
//下面这种方式是绝对路径,我测试也只能在虚拟主机的目录中,否则也无法通过,比如E:/PHPnow-1.5.1/php-5.2.8-Win32/PEAR,必须将PEAR拷贝到虚拟主机的目录下然后配置.
//再要注意,一定要以/来设定路径,而不能是\,如果指定为E:\PHPnow-1.5.1\vhosts\xxh.com\Library\PEAR也无法测试通过
//ini_set("include_path", "E:/PHPnow-1.5.1/vhosts/xxh.com/Library/PEAR");
include_once("Library/PEAR/DB.php");