PHP calls the full installation configuration documentation for Java

Source: Internet
Author: User
1. Windows installation configuration process

1.1. Apache and PHP installation configuration

Apache and PHP can be used in the decompression version, the installation version, the Suite edition.

The following is an example of the decompression version:

1, the decompression version does not need to install, decompression and put in any directory can be.

2, configure the Apache support for PHP, configuration process, see the network itself.

3, the software version of the demo test is: apache2.2.6, php5.3.5, javabridge5.4.4; The software version can be selected by itself, but it is guaranteed to be compatible with each other.

1.2. Configuration of Javabridge

1, confirm the configuration of PHP and Apache environment, configure Javabridge, so that PHP support Java calls.

The Javabridge jar package and the corresponding Java directory will be placed in any directory.

2, in the PHP project to introduce the Java directory Java.inc (including Java.inc and javaproxy.php), such as: require_once (". /java/java.inc ");

Note the path problem that is introduced, namely: /java/java.inc part; Refer to the Secutil.php page introduction method of Demo.

3, the PHP call jar package into the system used by the JRE of the Lib under the ext, such as C:\Java\jdk1.6.0_20\jre\lib\ext

4, start Javabridge can.

There are three ways to start Javabridge:

(1), directly double-click the boot jar package.

(2), can cmd command run start Java-jar Javabridge.jar servlet_local:8080 (in ext directory)

(3), you can use batch processing to run the second method (batch and jar package the same directory)

1.3. Running Phpdemo

1, verify Javabridge is normal, can be tested by calling Java API, such as: test.php

Require_once ("Java/java.inc");

Header ("content-type:text/html; Charset=utf-8 ");

Get instance of Java class Java.lang.System in PHP

$system = new Java (' Java.lang.System ');

$s = new Java ("Java.lang.String", "Php-java-bridge config ...

");

Echo $s;

Demonstrate property access

print ' Java version= '. $system->getproperty (' java.version '). '
';

print ' Java vendor= '. $system->getproperty (' Java.vendor '). '
';

print ' os= '. $system->getproperty (' Os.name '). ' '.

$system->getproperty (' os.version '). ' On '.

$system->getproperty (' Os.arch '). '
';

java.util.Date Example

$formatter = new Java (' Java.text.SimpleDateFormat ',

"Eeee, MMMM dd, yyyy ' at ' h:mm:ss a zzzz");

Print $formatter->format (new Java (' java.util.Date '));

?>

Note: Be careful to modify the introduction path inside.

2, if Javabridge, start Apache and Javabridge; Access Phpdemo index.php.

Attention:

1, if access error NOTICE modify php.ini configuration file, error_reporting = E_all & ~e_notice

2, please keep Javabridge and java.inc version of the same.

3, the process of calling Java, if there are errors, will be displayed through the Javabridge window and the page, such as the calling method name does not exist.


2. Linux installation configuration process

2.1. Apache Installation

2.1.1. Installation version

Httpd-2.2.29.tar.gz

2.1.2. Installation Steps

Tar? zxvf httpd-2.2.29.tar.gz

./configure

Make

Make install

2.1.3. Launch Apache

Startup Apache:/usr/local/apache2/bin/apachectl start after successful installation

To see if the startup was successful: Ps-ef |grep httpd executes, the following occurs when the startup succeeds.

2.1.4. Apache FAQ

Attention:

1. The following prompt will appear when the GCC compiler is not installed (/configure):

Configure:error:in '/USR/LOCAL/TONGSOFTWARE/HTTPD-2.2.29/SRCLIB/APR ':

Configure:error:no acceptable C compiler found in $PATHSee ' Config.log ' For more detailsconfigure failed for SRCLIB/APR

The system prompts that the GCC compiler is not installed, install the compiler: Yum-y install GCC.

2, make and make install to appear as follows the installation success:

......

Mkdir/usr/local/apache2/man

Mkdir/usr/local/apache2/man/man1

Mkdir/usr/local/apache2/man/man8

Mkdir/usr/local/apache2/manual

MAKE[1]: Leaving directory '/root/aphp/httpd-2.2.29 '

[Root@device httpd-2.2.29]#

Locate the installation path where you can start Apache.

3, if the installation is a high version or some other version of Apache, such as httpd-2.4.12.tar.gz, the compile will appear the following error message:

........

Checking for APR ... no

Configure:error:APR not found. Please read the documentation.

The installation solution is as follows:

The solution is as follows:

#./configure--prefix ... When checking the editing environment, it appears:

Checking for APR ... no

Configure:error:APR not found. Please read the documentation.

can use./configure? Help | grep Apr view Help.

--WITH-INCLUDED-APR use bundled copies of Apr/apr-util

--with-apr=path prefix for installed Apr or the full PATH to Apr-config

--with-apr-util=path prefix for installed Apus or the full PATH to

Install Apr (Apache portable Runtime)

[Root@localhost ~]# cd/tmp/52lamp///Source storage location

[Root@localhost 52lamp]# tar-zxvf apr-1.4.2.tar.gz//unzip-o apr-1.4.2.zip

[Root@localhost 52lamp]# CD apr-1.4.2

[Root@localhost apr-1.4.2]#./configure

[Root@localhost apr-1.4.2]# make

[Root@localhost apr-1.4.2]# make install

Check that the compilation environment appears again

Checking for Apr-util ... No

Configure:error:apr-util not found. Please read the documentation.

[Root@localhost httpd-2.2.16]#./configure? Help | grep apr-util

--with-apr-util=path prefix for installed Apus or the full PATH to

[Root@localhost 52lamp]# TAR-ZXVF apr-util-1.3.9.tar.gz

[Root@localhost 52lamp]# CD apr-util-1.3.9

[Root@localhost apr-util-1.3.9]#./configure--prefix=/usr/local/apr-util--WITH-APR=/USR/LOCAL/APR

[Root@localhost apr-util-1.3.9]# make

[Root@localhost apr-util-1.3.9]# make install

./configure still prompts Apr-util not found, which appears after adding--WITH-APR=/USR/LOCAL/APR--with-apr-util=/usr/local/apr-util

Configure:error:pcre-config for Libpcre not found. PCRE is required and available from http://pcre.org/

[Root@localhost httpd-2.2.16]#./configure? Help | grep pcre

--with-pcre=path Use external Pcre library

[Root@localhost 52lamp]# Unzip-o Pcre-8.10.zip

[Root@localhost 52lamp]# CD pcre-8.10

[root@localhost cd pcre-8.10]#./configure--prefix=/usr/local/pcre

[Root@localhost CD pcre-8.10]# make

[root@localhost CD pcre-8.10]# make install

Add parameter--with-apr=/usr/local/apr/--with-apr-util=/usr/local/apr-util/when continuing to install Apache/httpd,./configure--with-pcre=/ Usr/local/pcre, this problem is solved.

Note: httpd-2.4.12.tar.gz installation of this procedure is not pro-test.

2.2. Install PHP

2.2.1. installation version

Php-5.4.40.tar.gz

2.2.2. Installation Steps

Tar? zxvf php-5.4.40.tar.gz

./configure--prefix=/usr/local/php/--with-apxs2=/usr/local/apache2/bin/apxs (note compile here, be sure to compile the Apache module in, and--WITH-APXS2=/USR/LOCAL/APACHE2/BIN/APXS)

Make

Make install

2.2.3. PHP FAQ

Attention:

1. If the Libxml2-python and Libxml2-devel packages are not installed, the following error will occur at compile time:

Configure:error:xml2-config not found. Please check your LIBXML2 installation

J Solution: Install Libxml2-python and libxml2-devel Pack: Yum-y installs Libxml2-python libxml2-devel

2. The following error occurred when make

1.Perl is not installed

2. APXS is not found. Try to pass the path using--WITH-APXS2=/PATH/TO/APXS

3. Apache wasn't built using--enable-so (the APXS usage page is displayed)

The output of/usr/local/apache/bin/apxs follows:./configure:line 6669:/usr/local/apache/bin/apxs:permission denied

Solution: 1, first install Perl package, 2, APXS permissions problem, that is, add executable permissions;

2.2.4. Configuring PHP

Create a configuration file in the specified profile directory

[Root@localhost php-5.4.40]# CP Php.ini-dist/usr/local/php/lib/php.ini

2.2.5. Adding Apache to PHP support

[Root@localhost php-5.4.40]# Vi/usr/local/php/lib/php.ini

Find AddType application/x-gzip gz tgz, add a line below

AddType application/x-httpd-php. php. php3

Restart Apache.

Write index.php file, test support is normal.

Phpinfo ();

?>

2.3. Installation Configuration Javabridge

2.3.1. Installation-free configuration Javabridge

1, put Javabridge.jar to any location, generally placed in the PHP folder, such as/usr/local/php/etc

2, the Java folder with this Javabridge.ja R is placed anywhere in the file, generally placed in the PHP folder, such as/usr/local/php/etc, and then note the path of the reference problem.

such as: require_once ("/usr/local/php/etc/java/java.inc");

3. Place the required jar package under the JRE (i.e.,/usr/java/jdk1.6.0_20/jre/lib/ext), then project reference

Linux

Java_require ('/usr/java/jdk1.6.0_20/jre/lib/ext/svsclient.jar ');

Java_require ('/usr/java/jdk1.6.0_20/jre/lib/ext/bjca_log.jar ');

4. Start Javabridge

Java-jar javabridge.jar servlet_local:8080 This command starts cannot close the window and does not run in the background

Java-jar Javabridge.jar servlet_local:8080 & This command starts to close the window and runs in the background (sometimes you need to CTRL + C interrupt before closing the window)

5. To see if successful PS-EF |grep 8080 started successfully:

6, verify Javabridge is normal, can be tested by calling Java API, such as: test.php

Require_once ("Java/java.inc");

Header ("content-type:text/html; Charset=utf-8 ");

Get instance of Java class Java.lang.System in PHP

$system = new Java (' Java.lang.System ');

$s = new Java ("Java.lang.String", "Php-java-bridge config ...

");

Echo $s;

Demonstrate property access

print ' Java version= '. $system->getproperty (' java.version '). '
';

print ' Java vendor= '. $system->getproperty (' Java.vendor '). '
';

print ' os= '. $system->getproperty (' Os.name '). ' '.

$system->getproperty (' os.version '). ' On '.

$system->getproperty (' Os.arch '). '
';

java.util.Date Example

$formatter = new Java (' Java.text.SimpleDateFormat ',

"Eeee, MMMM dd, yyyy ' at ' h:mm:ss a zzzz");

Print $formatter->format (new Java (' java.util.Date '));

?>

Note: Be careful to modify the introduction path inside.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.