Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1198270
  • 博文数量: 253
  • 博客积分: 5892
  • 博客等级: 大校
  • 技术积分: 1942
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-24 14:20
文章分类

全部博文(253)

文章存档

2012年(98)

2011年(155)

分类: Python/Ruby

2012-01-13 17:00:13

情景:

这两天公司要与招商银行的网银进行对接,系统中已经安装了支持java预言的1.6最新版本的jdk,但是现在需要的让系统中php程序支持java,才能完成,下面对此情况进行简单说明:

使用php-java-bridgePHP5支持java

一、下载:

http://ncu.dl.sourceforge.net/project/php-java-bridge/RHEL_FC%20SecurityEnhancedLinux/php-java-bridge_5.5.4.1/php-java-bridge_5.5.4.1.tar.gz

最新的版本是:php-java-bridge_6.1.2.1.tar.gz

但不能使用这个版本,因为这个版本中缺少一个函数:java_require

二、首先说明一下安装不成功的情况:

解压:

tar zxvf php-java-bridge_5.5.4.1.tar.gz

进入目录:

cd php-java-bridge-5.5.4.1/

执行phpize

/usr/local/php/bin/phpize

编译:

./configure --with-java=$JAVA_HOME --with-php-config=/usr/local/php/bin/php-config

编译的过程和结果都是没问题的,但接下来的make操作就要注意了:

make

报错:

phpdoc -j -c PHPDocConfig.ini >/dev/null

/bin/sh: phpdoc: command not found

make[1]: *** [JavaRaw.inc] 错误 127

make[1]: Leaving directory `/root/downloads/jdk/php-java-bridge-5.5.4.1/server'

make: *** [/root/downloads/jdk/php-java-bridge-5.5.4.1/modules/stamp] 错误 2

错误信息中提示没有phpdoc 命令。

在网上查阅了大量资料,知道phpdoc命令是安装phpDocumentor后生成的,phpDocumentor的安装又是有phppear模块完成的。

三、安装pear,为安装phpDocumentor做准备

根据网络提供的大量资料显示,所以我们首先安装pear

同样查阅了大量的网络资料来完成。

安装pear需要使用php命令来执行一个go-pear.php的文件来完成:

go-pear.php文件的获取:

访问:

将整个网页内容复制下来并存储为go-pear.php即可。

我们这里可以使用vim命令建立go-pear.php文件,将内容复制进去,保存,增加执行权限即可。

用php命令执行go-pear.php

/usr/local/php/bin/php go-pear.php

出现如下提示:

Welcome to go-pear!

Go-pear will install the 'pear' command and all the files needed by

it. This command is your tool for PEAR installation and maintenance.

Go-pear also lets you download and install the following optional PEAR

packages: PEAR_Frontend_Web-beta, PEAR_Frontend_Gtk2, MDB2.

If you wish to abort, press Control-C now, or press Enter to continue:

回车,出现如下内容:

HTTP proxy (), or Enter for none::

再回车,出现如下内容,提示你安装位置:

Below is a suggested file layout for your new PEAR installation. To

change individual locations, type the number in front of the

directory. Type 'all' to change all of them or simply press Enter to

accept these locations.

1. Installation prefix ($prefix) : /root/downloads/jdk

2. Temporary files directory : $prefix/temp

3. Binaries directory : $prefix/bin

4. PHP code directory ($php_dir) : $prefix/PEAR

5. Documentation base directory : $php_dir/docs

6. Data base directory : $php_dir/data

7. Tests base directory : $php_dir/tests

1-7, 'all' or Enter to continue:

我们可以在命令行后输入1-7和all或者直接回车继续,

我们这里选择输入all,回车。

上一步选择all以后,就要对每一项的安装目录进行定义,这个根据变量提示来确定,这里之定义了四项,定义一项回车一次:

1-7, 'all' or Enter to continue: all

Installation prefix ($prefix) [/root/downloads/jdk] :

Temporary files directory [$prefix/temp] :

Binaries directory [$prefix/bin] : /usr/bin

PHP code directory ($php_dir) [$prefix/PEAR] : /usr/local/php/bin

Documentation base directory [$php_dir/docs] : /usr/local/php/docs

Data base directory [$php_dir/data] : /usr/local/php/data

Tests base directory [$php_dir/tests] :

回车后,返回刚才定义的信息:

Below is a suggested file layout for your new PEAR installation. To

change individual locations, type the number in front of the

directory. Type 'all' to change all of them or simply press Enter to

accept these locations.

1. Installation prefix ($prefix) : /root/downloads/jdk

2. Temporary files directory : $prefix/temp

3. Binaries directory : /usr/bin

4. PHP code directory ($php_dir) : /usr/local/php/bin

5. Documentation base directory : /usr/local/php/docs

6. Data base directory : /usr/local/php/data

7. Tests base directory : $php_dir/tests

1-7, 'all' or Enter to continue:

到这里,再回车:

The following PEAR packages are bundled with PHP: PEAR_Frontend_Web-beta,

PEAR_Frontend_Gtk2, MDB2.

Would you like to install these as well? [Y/n] :

输入Y,继续:

Loading zlib: ok

Bootstrapping Installer...................

Bootstrapping PEAR.php............(remote) ok

Bootstrapping Archive/Tar.php............(remote) ok

Bootstrapping Console/Getopt.php............(remote) ok

Extracting installer..................

Downloading package: PEAR.............ok

Downloading package: Structures_Graph....ok

Preparing installer..................

Updating channel "doc.php.net"

Update of Channel "doc.php.net" succeeded

Updating channel "pear.php.net"

Update of Channel "pear.php.net" succeeded

Updating channel "pecl.php.net"

Update of Channel "pecl.php.net" succeeded

Installing selected packages..................

Downloading and installing package: PEAR.............warning: pear/PEAR requires package "pear/Archive_Tar" (recommended version 1.3.7)

warning: pear/PEAR requires package "pear/Structures_Graph" (recommended version 1.0.3)

warning: pear/PEAR requires package "pear/Console_Getopt" (recommended version 1 .2.3)

warning: pear/PEAR requires package "pear/XML_Util" (recommended version 1.2.1)

downloading PEAR-1.9.1.tgz ...

Starting to download PEAR-1.9.1.tgz (293,587 bytes)

......................................done: 293,587 bytes

install ok: channel://pear.php.net/PEAR-1.9.1

PEAR: Optional feature webinstaller available (PEAR's web-based installer)

PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)

PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)

PEAR: To install optional features use "pear install pear/PEAR#featurename"

Installing bootstrap package: Structures_Graph.......install ok: channel://pear. php.net/Structures_Graph-1.0.3

Downloading and installing package: Archive_Tar-stable.......downloading Archive_Tar-1.3.7.tgz ...

Starting to download Archive_Tar-1.3.7.tgz (17,610 bytes)

...done: 17,610 bytes

install ok: channel://pear.php.net/Archive_Tar-1.3.7

Downloading and installing package: Console_Getopt-stable.......downloading Console_Getopt-1.2.3.tgz ...

Starting to download Console_Getopt-1.2.3.tgz (4,011 bytes)

...done: 4,011 bytes

install ok: channel://pear.php.net/Console_Getopt-1.2.3

Downloading and installing package: PEAR_Frontend_Web-beta.......downloading PEAR_Frontend_Web-0.7.4.tgz ...

Starting to download PEAR_Frontend_Web-0.7.4.tgz (53,321 bytes)

...done: 53,321 bytes

downloading HTML_Template_IT-1.3.0.tgz ...

Starting to download HTML_Template_IT-1.3.0.tgz (23,309 bytes)

...done: 23,309 bytes

install ok: channel://pear.php.net/HTML_Template_IT-1.3.0

install ok: channel://pear.php.net/PEAR_Frontend_Web-0.7.4

Downloading and installing package: PEAR_Frontend_Gtk2.......Did not download optional dependencies: pear/XML_Parser, pear/XML_Util, use --alldeps to download automatically

Did not download optional dependencies: pear/System_Command, use --alldeps to download automatically

pear/PEAR_Frontend_Gtk2 requires PHP extension "php-gtk" (version >= 2.0.0dev)

pear/Config can optionally use package "pear/XML_Parser"

pear/Config can optionally use package "pear/XML_Util"

pear/Gtk2_EntryDialog requires PHP extension "php-gtk" (version >= 2.0.0dev)

pear/Gtk2_FileDrop requires PHP extension "php-gtk" (version >= 2.0.0dev)

pear/MIME_Type can optionally use package "pear/System_Command"

downloading Config-1.10.11.tgz ...

Starting to download Config-1.10.11.tgz (27,939 bytes)

...done: 27,939 bytes

downloading MIME_Type-1.2.0.tgz ...

Starting to download MIME_Type-1.2.0.tgz (11,581 bytes)

...done: 11,581 bytes

install ok: channel://pear.php.net/Config-1.10.11

install ok: channel://pear.php.net/MIME_Type-1.2.0

Downloading and installing package: MDB2.............downloading MDB2-2.4.1.tgz ...

Starting to download MDB2-2.4.1.tgz (119,790 bytes)

...done: 119,790 bytes

install ok: channel://pear.php.net/MDB2-2.4.1

MDB2: Optional feature fbsql available (Frontbase SQL driver for MDB2)

MDB2: Optional feature ibase available (Interbase/Firebird driver for MDB2)

MDB2: Optional feature mysql available (MySQL driver for MDB2)

MDB2: Optional feature mysqli available (MySQLi driver for MDB2)

MDB2: Optional feature mssql available (MS SQL Server driver for MDB2)

MDB2: Optional feature oci8 available (Oracle driver for MDB2)

MDB2: Optional feature pgsql available (PostgreSQL driver for MDB2)

MDB2: Optional feature querysim available (Querysim driver for MDB2)

MDB2: Optional feature sqlite available (SQLite2 driver for MDB2)

MDB2: To install optional features use "pear install pear/MDB2#featurename"

******************************************************************************

WARNING! The include_path defined in the currently used php.ini does not

contain the PEAR PHP directory you just specified:

If the specified directory is also not in the include_path used by

your scripts, you will have problems getting any PEAR packages working.

到这里提示如下,提示是否更改php.ini文件

Would you like to alter php.ini ? [Y/n] :

选择Y,继续:

php.ini include_path updated.

Current include path : .:/usr/local/php/lib/php

Configured directory : /root/downloads/jdk/PEAR

Currently used php.ini (guess) : /usr/local/apache2/conf/php.ini

Press Enter to continue:

回车,继续,出现提示的地方就按照提示输入信息继续,直到完成!

四、用pear list可以查看安装了的pear包:

Package Version State

Archive_Tar 1.3.7 stable

Config 1.10.11 stable

Console_Getopt 1.2.3 stable

HTML_Template_IT 1.3.0 stable

MDB2 2.4.1 stable

MIME_Type 1.2.0 stable

PEAR 1.9.1 stable

PEAR_Frontend_Web 0.7.4 beta

Structures_Graph 1.0.3 stable

四、安装完了pear后,使用pear来安装PhpDocumentor

首先查找到pear安装位置:

find / -name pear

结果:

/usr/bin/pear

执行安装:

/usr/bin/pear install PhpDocumentor

Did not download optional dependencies: pear/XML_Beautifier, use --alldeps to download automatically

pear/PhpDocumentor can optionally use package "pear/XML_Beautifier" (version >= 1.1)

downloading PhpDocumentor-1.4.3.tgz ...

Starting to download PhpDocumentor-1.4.3.tgz (2,423,486 bytes)

..........

当出现如下信息的时候就说明phpdoc安装完成了:

install ok: channel://pear.php.net/PhpDocumentor-1.4.3

注意:可能PhpDocumentor-1.4.3的服务器在美国加州,尽管软件只有不到3M,安装过程相当慢,有可能还会断掉,如果出现这样的情况需要多试几次才行。

五、接下来就是重新编译安装php-java-bridge-5.5.4.1了:

进入php-java-bridge-5.5.4.1的目录:

执行phpize

/usr/local/php/bin/phpize

编译:

./configure --with-java=$JAVA_HOME --with-php-config=/usr/local/php/bin/php-config

安装:

make

make install

注意:如果在make 过结束出现错误,那么请执行make clean清理一下,重新编译后,再make 就可以了。

配置:

编辑php.ini文件:

vim /usr/local/apache2/conf/php.ini

添加如下内容:

[Java]

java.java_home="/usr/local/java/jdk1.6/"

java.java="/usr/local/java/jdk1.6/jre/bin/java"

java.log_file="/var/log/php-java-bridge.log"

java.classpath="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/JavaBridge.jar"

java.libpath="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"

extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"

extension = java.so

重启apache

service httpd restart

访问phpinfo页面:

如果有java模块,就说明安装成功了。

阅读(2906) | 评论(0) | 转发(0) |
0

上一篇:CentOS 6.0 Optimize

下一篇:D-Bus体系

给主人留下些什么吧!~~