Xampp and PHP Java Bridge
Xampp and PHP Java Bridge
Page 1
Page 2
pre-requisites
softwarecomponents
System XAMPP Linux,DistributionSuSE9.2Professional Version1.5.0 availableathttp://www.apachfriends.org Package: xampplinux1.5.0.tar.gz PHP/Java Bridge Version3.0.4 availableathttp://phpjavabridge.sourceforge.net/ Package: phpjavabridge3.0.41.FC4.i386.rpm(compiledrpmforFedoraCore4) Source: phpjavabridge_3.0.4tar.bz2
Webalizer2.01 pdfclass009e ncurses5.8 mod_perl2.0.1 FreeTDS0.63 gettext0.11.5 IMAPCClient2004e OpenLDAP(client)2.3.11 mhashlibrary0.8.18 mcryptlibrary2.5.7 cURL7.13.1 SQLite2.8.9(incaseofPHP5:2.8.14) phpSQLiteAdmin0.2 eAccelerator0.9.3 libapreq2.04dev FPDF1.5.3
Step 1: Install the XAMPP package Unpack the XAMPP package into directory '/opt'. An automatically created subdirectory '/opt/lampp' is filled with the package content. Apply the following console entry:
# tar xvfz xampp-linux-1.5.0.tar.gz -C '/opt'
Page 3
Note:Thebasedirectoryintheproceedingsofthisdocumentisdefinedas '/opt/lampp'. Step 2: Create a startup script for XAMPP The following startup script should be saved into directory '/etc/init.d'. At system startup, different services are going to be executed by start scripts. These scripts are originally located in directory '/etc/init.d' and they are registered by a soft link in at least one run level directory from 'rc0.d' to 'rc6.d'. All soft linked start scripts in one associated run level directory are called by the entry the run level master script '/etc/init.d/rc'. Startup script: /etc/init.d/lampp
#! /bin/sh # Written in 2005 by PJS # # Author: # Peter J. Siegel <peter@peter-siegel.de>, 2005 # # /etc/init.d/lampp # # Description: Start the XAMPP environment # ### END INIT INFO XAMPP_DIR=/opt/lampp case "$1" in start) echo "Starting LAMPP" $XAMPP_DIR/lampp start ;; stop) echo "Shutting down LAMPP" $XAMPP_DIR/lampp stop ;; restart) ## Stop the service and regardless of whether it was ## running or not, start it again. $0 stop $0 start ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 ;; esac exit 0
Page 4
The start script can be executed automatically on system bootup. This can be set up with the runlevel editor in YaST:
Page 5
AninteractiveconfigurationofpasswordsforXAMPP,MySQLphpMyAdminand ProFTPdshouldbefulfilledwiththeselines:
XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: XAMPP: Quick security check... Your XAMPP pages are NOT secured by a password. Do you want to set a password? [yes] Password: Password (again): Password protection active. Please use 'lampp' as user name! MySQL is accessable via network. Normally that's not recommended. Do you want me to turn it off? [yes] Turned off. The MySQL/phpMyAdmin user pma has no password set!!! Do you want to set a password? [yes] Password: Password (again): Setting new MySQL pma password Setting phpMyAdmin's pma password to the new one. MySQL has no root password set!!! Do you want to set a password? [yes] Password: Password (again): Setting new MySQL root password. Change phpMyAdmin's authentication method. The FTP password is still set to 'lampp'. Do you want to change the password? [yes] Password: Password (again): Reload ProFTPD... Done.
LaunchingtheXAMPPpageinawebbrowserunderEchnaton'sIPaddresswillshow aloginwindowlikethis:
Page 6
LaunchingthephpMyAdminpageinawebbrowserundertheserveraddress "http://192.168.10.3/phpmyadmin"willshowaloginwindowlikethis:
Installing PHP/Java Bridge with a precompiled package Forconvenienceit'sabettersolutiontodownloadandinstallthecompiledpackage phpjavabridge3.0.41.FC4.i386.rpm.DespiteitismadefortheFedoraLinux distributionyoucanuseitforSuSELinux9.x,too. Step 1: Package Installation Performthepackageinstallationbyfollowingcommandline: # rpm -i php-java-bridge-3.0.4-1.FC4.i386.rpm --nodeps The'nodeps'optionshouldpreventanydependencymessagesthatmaybelongto missingPHPpackages.EveryneededPHPcomponentisjustinstalledwithXAMPP thatisunknownfortheRPMpackagemanager. Step 2: Directory Changes AfterpackageinstallationthefilesforPHP/JavaBridgeareinstalledintothese directories:
/etc/init.d/php-java-bridge /etc/php.d/java.ini /usr/lib/php/modules/JavaBridge.jar /usr/lib/php/modules/RunJavaBridge /usr/lib/php/modules/java.so /usr/lib/php/modules/libnatcJavaBridge.so /usr/sbin/php-java-bridge
Thedocumentationissavedinto/usr/share/doc/phpjavabridge3.0.4.
Page 7
Step 3: New Configuration Entries In File php.ini ThePHP/JavaBridgeextensionanditsconfigurationneedtogetloadedbyPHPas partoftheXAMPPframework.Forthisreasonsomeadditionalentrieshavetobe made inthePHPconfigurationfile/opt/lampp/etc/php.ini,writtenattheendof sectionDynamicExtensions:
;;;;;;;;;;;;;;;;;;;;;;;;; ; php-java-bridge-3.0.4 ; ;;;;;;;;;;;;;;;;;;;;;;;;; extension = java.so [java] java.log_level="3" java.log_file="/opt/lampp/logs/php-java-bridge.log" java.java_home="/opt/lampp/java_home" java.java="/opt/lampp/java_home/bin/java" java.wrapper="/opt/lampp/lib/php/extensions/no-debug-non-zts-20041030/RunJavaBridge"
The directory /opt/lampp/java_home is a soft link that points to a directory containing the installed JRE. On most systems it is set in $JAVA_HOME. Followingcommandlinecreatesthissoftlink:
# ln -s $JAVA_HOME /opt/lampp/java_home
Page 8
Thestartscripthastobemodifiedtothechangeddirectories.Allchangesare highlighted.
#!/bin/bash # # php-java-bridge Startup script for the PHP/Java Bridge # # chkconfig: - 84 16 # description: The PHP/Java Bridge allows PHP scripts to access java based \ # applications running in a java application server # processname: php-java-bridge # pidfile: /var/run/php-java-bridge.pid # config: /etc/php.d/java.ini # Source function library. # . /etc/rc.d/init.d/functions prog=/opt/lampp/bin/php-java-bridge RETVAL=0 start() { echo -n $"Starting $prog: " exec $prog & RETVAL=$? echo [ $RETVAL = 0 ] && touch $prog return $RETVAL } stop() { echo -n $"Stopping $prog: " killproc $prog RETVAL=$? echo [ $RETVAL = 0 ] && rm -f $prog.pid } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status $prog RETVAL=$? ;; restart) stop start ;; *) echo $"Usage: $prog {start|stop|restart|status}" exit 1 esac exit $RETVAL
Page 9
ExecutethepsAshellcommandthatshowsallrunningprocesses.Thethreads belongingtoXAMPPareextendedbyanadditionalJavathread:
11250 11260 11287 11290 11291 ? pts/3 pts/3 ? ? 00:00:00 00:00:00 00:00:00 00:00:00 00:00:00 proftpd mysqld_safe mysqld httpd java
Installing PHP/Java Bridge by source code compiling Precompiled packages for the PHP/Java Bridge are built against a certain PHP version.IftheJavasharedobject(java.so)dependsonaPHPversionthatdiffersfrom theinstalledone(e.g5.0vs.5.1.1)followingerrormightberisingup:
PHP warning: PHP startup: java.so: Cannot open shared object file no such file or directory in Unknown on line 0 PHP warning: PHP startup: (null): Unable to initialize module Module compiled with module API=20041030, debug=0, thread-safety=0 PHP compiled with module API=20050922, debug=0, thread-safety=0 These options need to match
Page 10
Liketheerrormessagesaysclearly:TheAPIversionsatcompiletimehavetobethe same.YoucanachievethisbycompilingthePHP/JavaBridgesourcecodeagainstthe installedPHPversion. Compile the PHP/Java Bridge source Assumingyouhaveextractedthesourcetreepackedinthetarfilewithfollowing commandline
# cat php-java-bridge_3.0.4.tar.bz2 | bunzip2 | tar xvf -
andchangetotheunpackedsourcedirectorywith
# cd php-java-bridge-3.0.4
Startthecompilationwith
# /opt/lampp/bin/phpize && ./configure --disable-servlet --with-java=/opt/lampp/java_home --with-php-config=/opt/lampp/bin/php-config