The steps to integrate PHP and Drupal with Apache are well-documented in an IBM tutorial for Windows
and Linux
. You'll need to register for the IBM website to view it, but it's well worth the few minutes it takes. Note that these installation tutorials are part of a very good larger series on Drupal from IBM, available here
as an RSS feed.
Before you begin the tutorial I'd suggest you back up your Apache configuration, in case something breaks in the course of Drupal and PHP integration.
Go through the tutorial, installing PHP, MySql, Drupal, etc. but skipping the step to install Apache, as you've already installed Apache or IHS in Second Steps. Of course you can install or reference a database of your choice, but I think it's better to keep things simple at this stage and use MySql, switching out the data layer at a later stage of development.
Configure Apache, MySQL and PHP per the tutorial. In essence this involces:
For the record, my Apache httpd.conf looks like this at the end:
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL PHPIniDir "C:\\PHP\\" LoadModule php5_module "C:\\PHP\\php5apache2.dll" #END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL # Include virtual hosts Include "C:/apache2/Apache2/conf/vhosts.d/drupal.development.conf" # End virtual hosts # Begin IBM Plugin for WebSphere LoadModule was_ap20_module "C:\Program Files\IBM\WebSphere\Plugins\bin\mod_was_ap20_http.dll" WebSpherePluginConfig "C:\Program Files\IBM\WebSphere\Plugins\config\localApache\plugin-cfg.xml" # End IBM Plugin for WebSphere
My drupal.development.conf file defining the drupal virtual host looks like:
<VirtualHost 127.0.0.1:80> ServerName drupal.development DocumentRoot "C:\data\drupal\drupal_development\drupal_development\drupal-5.2" <Directory "C:\data\drupal\drupal_development\drupal_development\drupal-5.2"> AllowOverride All Order Deny,Allow Deny from All Allow from 127.0.0.1 </Directory> CustomLog "C:\apache2\Apache2\logs\drupal_development-access.log" common ErrorLog "C:\apache2\Apache2\logs\drupal_development-error.log" </VirtualHost>
You need to modify your hosts file to use drupal.development to resolve to 127.0.0.1
127.0.0.1 localhost development drupal.development
Finally, the PHP.ini mods will look something like this:
; Windows: "\path1;\path2" include_path = ".;c:\php\includes;c:\Data\drupal\drupal_development\drupal_development\drupal-5.2"
Configure your site per the tutorial. When you're done you should see a standard drupal home page.
The Java.inc file running in your JavaBridge is the key to PHP integration. In order for an external PHP instance to correctly access the bridge the session needs to execute the instance of Java.inc that is running on the bridge using http.
I'd prefer this were externally configurable, but don't know enough about the bridge yet to do so.
PHP blocks http access to files out of the box as a security measure. You'll need to relax that prohibition to use the bridge, per the section below:
;;;;;;;;;;;;;;;;;; ; Fopen wrappers ; ;;;;;;;;;;;;;;;;;; ; Whether to allow the treatment of URLs (like http:// or ftp://) as files. allow_url_fopen = On ; Whether to allow include/require to open URLs (like http:// or ftp://) as files. allow_url_include = On
We'll need to find a better way later!
Let's make sure we did no harm. You backed up your old Apache configuration, right!
<?php ini_set( 'allow_url_fopen', 'on'); if (!extension_loaded('java')){ require_once("http://localhost:9080/JavaBridge/java/Java.inc"); } $session = java_session(); ?> <HTML> <TITLE>JSP session peeking</title> <BODY> <?php if (is_null($session->get("counter"))) { // If we're starting the counter, start it distinctively $session->put("counter", new Java("java.lang.Integer", 5)); } $counter = $session->get("counter"); echo "I'm peeking into a Java session from PHP to dredge up a counter<br/>"; echo "Hello, the hidden number is ", $counter->toString() ; ?> </BODY> </HTML>
As you see the code executes a require_once on the magical Java.inc in the bridge which gives us the ability to access a Java session. The remainder of the code prints out the value of a session counter.
Bring up the JavaBridge examples page as in Part 2, using a url like:
http://localhost:JavaBridge![]()




That's it. We've created a Java session variable from PHP, incremented it using JSP and then accessed it from outside the bridge using PHP.
On to Drupal integration