This document explains how to compile PHP with java on a Linux-ppc-installation. Specific on YellowDogLinux 2.2. Instructions for YDL 2.1 look here If you want an instruction to Linux i386 (great help for my work) you can find it here http://www.thelinuxpimp.com/main/modules.php?op=modload&name=News&file=article&sid=419
1. I started out with a server installation from YellowDogLinux 2.2 (Rome). This installs by default Apache 1.3.22, PHP 4.1.2, MySql, Perl and more. There is no X, so you have to make it all in a terminal. To set up a suitable development-environment you have to add/install binutils, gcc-compiler tools, glibc and glibc-devel, bison. This can be done from the install-cd or with yup. Run the command % yup config dist. Select distribution/version 2.2. Only one mirror are present aviable for version 2.2.
2. Grab a full version of java-SDK. Select a mirror from http://blackdown.org. In my case (Denmark) like this % curl -O ftp://sunsite.dk/mirrors/java-linux/JDK-1.3.1/ppc/FCS-02b/j2sdk-1.3.1-02b-FCS-linux-ppc.bin When the file is downloaded you have to make the shell-script executable % chmod +x j2sdk-1.3.1-02b-FCS-linux-ppc.bin Unpack/install the Java 2 SDK ex. in the directory /usr/local % ./j2sdk-1.3.1-02b-FCS-linux-ppc.bin If the j2sdk1.3.1 don't end up in the right place move or copy it with the command % cp -r j2sdk1.3.1 /usr/local Add j2sdk1.3.1/bin to your PATH - if installed in /usr/local % export PATH=/usr/local/j2sdk1.3.1/bin:$PATH To be sure that the system can find the new java-installation you must edit the file /etc/profile. Add this line at the bottom of the file: export PATH=/usr/local/j2sdk1.3.1/bin:$PATH Log out and log back and issue the % env command to verify that the proper PATH variabel is in effect. Edit the file /etc/ld.so.conf by adding the following two lines /usr/local/j2sdk1.3.1/jre/lib/ppc /usr/local/j2sdk1.3.1/jre/lib/ppc/classic Make the changes go into effect by typing % ldconfig Change to directory % cd /usr/local/j2sdk1.3.1/jre/lib/ppc (or wherever libjava.so is placed) and write the following command % ldd libjava.so The response you get back should contain no "not found" messages. If you get some "not found" errors you must edit the /etc/ld.so.conf with the path to the missing file and re-run ldconfig. When you are sure that all paths-issues are settled go to the next step.
3. Change to your home-directory. Download the php-sourcecode (same version of the PHP that you already are running) from php.net Select a mirror - in my case % curl -O http://dk.php.net/distributions/php-4.1.2.tar.gz Unpack the sourcecode with the command % tar -zxvf php-4.1.2.tar.gz cd to the new directory % cd php-4.1.2 php-4.1.2 had to be configured with the following % ./configure --with-apxs --with-java Running the configure-script will probably unveil some errors. It seems that no apxs (Apache utility for the DSO-modul) are present in the YDL-distribution of Apache. And maybe the configure-script can't find your Java. We will take care of this!
3.1 If no apxs are present you have to make a new build of Apache. You can make this in your home-directory. The only purpose with the build is to get apxs. Do it like this. Download the sourcecode nearest to the Apache-version you already are running. Find a suitable mirror - In my case % curl -O ftp://sunsite.auc.dk/pub/infosystems/www/apache/dist/httpd/apache_1.3.24.tar.gz After the download unpack the file % tar -zxvf apache_1.3.24.tar.gz cd to % cd apache_1.3.24 Decide where the new apache installation should be ex. /home/jens/myapache1.3.24 % ./configure --prefix=/home/jens/myapache1.3.24 --enable-shared=rewrite --enable-module=rewrite \ --enable-module=proxy --enable-shared=proxy % make % make install The whole process will take some time. If all goes well you will end up with a new directory myapache1.3.24. You will find the apxs in the sub-directory /bin of the new myapache1.3.24. Return to the php-4.1.2 in your home-directory and do this % make clean % ./configure --with-apxs=/home/jens/myapache1.3.24/bin/apxs --with-java=/usr/local/j2sdk1.3.1 If the configure-sript run without errors % make It will take some time to compile everything. After the compile is done, and there are no errors mentioned you will find libphp_java.so in modules and php_java.jar in ext/java. Copy these 2 files to your original php extensions directory (check in php.ini where it is): % cp php_java.jar /usr/lib/php4 % cp libphp_java.so /usr/lib/php4
4. Now you must edit the /etc/php.ini fil. Add the following lines (my example) at the bottom of the file: [Java] java.class.path = /usr/lib/php4/php_java.jar java.home = /usr/local/j2sdk1.3.1 java.library.path = /usr/lib/php4 java.library = /usr/local/j2sdk1.3.1/jre/lib/ppc/classic/libjvm.so extensions_dir = /usr/lib/php4 extension = libphp_java.so Restart Apache with the command % service httpd restart Test your php installation in a browser with a file (test.php) including the following <?php phpinfo() ?> Probably you have to use some other machine with X to test this. If you can see something like this in the php-info you have succeeded!
|Directive||Local Value||Master Value|
To test your php-with-java, make a file (testjava.php) and upload it to your web directory The following php-code are from php.net: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <HTML> <HEAD> <TITLE>testjava</TITLE> </HEAD> <BODY> <?php // get instance of Java class java.lang.System in PHP $system = new Java('java.lang.System'); // demonstrate property access print 'Java version='.$system->getProperty('java.version').' <br>'; print 'Java vendor=' .$system->getProperty('java.vendor').' <br>'; print 'OS='.$system->getProperty('os.name').' '. $system->getProperty('os.version').' on '. $system->getProperty('os.arch').' <br>'; // 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')); ?> </BODY> </HTML> In a browser you will see something like this: Java version=1.3.1 Java vendor=Blackdown Java-Linux Team OS=Linux 2.4.18-0.9a on ppc Monday, April 29, 2002 at 2:48:48 PM GMT+01:00
5. When you are finished, you can delete the downloaded files or directories used specific for the purpose of making the php-java modules with (ex.) the command: % rm -rf apache_1.3.24.tar.gz As editor I have used vi (default on most *nix-systemer). If you work a lot in a shell and need to know more about unix-commands and editors like vi or emacs look here Introduction to Unix, http://wks.uts.ohio-state.edu/unix_course/ Notes about Mac OSX: The layout of Mac OSX's java-implementation differs from the standard j2sdk. You will have no success trying compiling the php-sourcecode with java on Mac OSX without rewriting php's configure scripts. Anyway there are great support for OSX-users who wants php (without java-support) and MySql. Look at Marc Liyanage's homesite http://www.entropy.ch/home/. Or download Aaron Faby's Complete PHP, MySql, Apache, Tomcat packages from http://www.serverlogistics.com/ The release of php 4.3.0 in august 2002 promises full integration with OSX. More about this here http://www.php.net/release_4_2_0.php
YDL 2.1 notes: On YDL 2.1 you can almost do the same. Install YDL 2.1 with the full developer setup. When you see the X-window-login hit ctrl+alt+F1 to get in a terminal. (you can return to the X-login with the key-combination ctrl+alt+F7). Login as root. Check one of the YDL-2.1 mirrors for updates % yup update There are about 45 updates aviable for the developer setup, so this will take some time. After the update has finished install apache, php, MySql and proftpd % yup install apache apache-manual php mysql php-mysql proftpd Reboot % reboot If you want to use curl you must make it from source. There are no curl binaries aviable for YDL 2.1. But that's easy. Login via X. Use Mozilla to get the curl-sourcecode from http://curl.haxx.se Get the latest release curl-7.9.6.tar.gz Logout. Hit ctrl+alt+F1. Login as root. cd to your home directory where you have downloaded the curl sourcecode. Unpack the sourcecode % tar -zxvf curl-7.9.6.tar.gz cd into curl-7.9.6 % cd curl-7.9.6 % ./configure % make % make install
Proceed with the instructions for YDL 2.2
Other usefull links: PHP and Java: Greater Than the Sum of Its Parts? Web Development & Mac OS X