由于一客户需要与银行的网银支付系统进行对接,需要的让系统中php程序支持java, php-java-brige是php众多拓展模块(功能)中的一个,安装此模块之后,php就能自动调用Java语言编写的文件了,才能完成支付功能,下面对此情况进行简单说明:
软件 | 路径 | 版本 |
apache | /usr/local/apache | 2.2.22 |
php | /usr/local/php | 5.3.10 |
jdk | /usr/local/java | 1.6.0_25 |
java-bridge | 5.5.4.1 |
- [root@vm03 local]# chmod +x jdk-6u25-linux-x64.bin
- [root@vm03 local]# ./jdk-6u25-linux-x64.bin
- [root@vm03 local]# ln -sv jdk1.6.0_25 java
- [root@vm03 local]# vim /etc/profile //在最后添加一下内容
- JAVA_HOME=/usr/local/java
- [root@vm03 local]# . !$ //重新加载一下文件
- . /etc/profile
- [root@vm03 src]# wget
- [root@vm03 src]# /usr/local/php/bin/php go-pear.phar
- 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 base ($prefix) : /usr/local/php
- 2. Temporary directory for processing : /tmp/pear/install
- 3. Temporary directory for downloads : /tmp/pear/install
- 4. Binaries directory : /usr/local/php/bin
- 5. PHP code directory ($php_dir) : /usr/local/php/lib/php
- 6. Documentation directory : /usr/local/php/docs
- 7. Data directory : /usr/local/php/data
- 8. User-modifiable configuration files directory : /usr/local/php/cfg
- 9. Public Web Files directory : /usr/local/php/www
- 10. Tests directory : /usr/local/php/tests
- 11. Name of configuration file : /usr/local/php/etc/pear.conf
- 1-11, 'all' or Enter to continue: //此处你可以根据自己的情况进行修改,当然我这就直接默认了,直接回车!
- [root@vm03 src]# /usr/local/php/bin/pear channel-update pear.php.net //更新一下pear.php.net
- Updating channel "pear.php.net"
- Channel "pear.php.net" is up to date
- [root@vm03 src]# /usr/local/php/bin/pear PhpDocumentor //安装phpdocumentor,此过程会自动从网上下载包进行解压和安装。
- Command 'PhpDocumentor' is not valid, try 'pear help'
- [root@vm03 src]# /usr/local/php/bin/pear install PhpDocumentor
- WARNING: "pear/PhpDocumentor" is deprecated in favor of "channel://pear.phpdoc.org/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.4.tgz ...
- Starting to download PhpDocumentor-1.4.4.tgz (1,534,088 bytes)
- ..............................................................................................................................................................................................................................................................................................................done: 1,534,088 bytes
- install ok: channel://pear.php.net/PhpDocumentor-1.4.4 //显示此内容表示安装OK!
- [root@vm03 src]# vim /etc/profile 添加一下内容:
- PATH=$PAHT:/usr/local/php/bin
- [root@vm03 src]# source /etc/profile
- [root@vm03 src]# yum install ant -y
- [root@vm03 src]#
- [root@vm03 src]# tar xf php-java-bridge_5.5.4.1.tar.gz
- [root@vm03 src]# cd php-java-bridge-5.5.4.1/
- [root@vm03 php-java-bridge-5.5.4.1]# /usr/local/php/bin/phpize
- Configuring for:
- PHP Api Version: 20090626
- Zend Module Api No: 20090626
- Zend Extension Api No: 220090626
- [root@vm03 php-java-bridge-5.5.4.1]# ./configure --with-java=/usr/local/java --with-php-config=/usr/local/php/bin/php-config
- [root@vm03 php-java-bridge-5.5.4.1]# make
- ……
- Build complete.
- Don't forget to run 'make test'. //显示这些内容可以make install了
- [root@vm03 php-java-bridge-5.5.4.1]# make install
- Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
- [root@vm03 ~]# vim /usr/local/php/etc/php.ini // 在最后添加一下内容
- [Java]
- java.java_home="/usr/local/java"
- java.java="/usr/local/java/jre/bin/java"
- java.log_file="/var/log/php-java-bridge.log"
- java.classpath="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/JavaBridge.jar"
- java.libpath="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"
- extension_dir="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"
- extension=java.so
整个过程配置完成!