OC4J and php

Card Puncher Data Processing

Getting PHP to run in OC4J is trivial: simply make sure that the directory from PHP is in the executable path and without space on it.

Configuration

Every web application can specify a set of welcome-files.

In WEBAPP/WEB-INF/web.xml, make sure you have the following:

<welcome-file-list>
<welcome-file>index.php</welcome-file>
</welcome-file-list>

Note that running PHP from within OC4J can be not only interesting, but very slow compared to using JSP or servlets instead. Consider fronting OC4J with Apache or something else that can embed PHP directly to save the extra overhead of external process invocation.

In global-web-application.xml :

<servlet>
   <servlet-name>php</servlet-name>
      <servlet-class>com.evermind.server.http.CGIServlet</servlet-class>
      <init-param>
        <param-name>interpreter</param-name>
        <param-value>php</param-value>
      </init-param>
    </servlet>

php must not be installed in a path with space like in the program files directory

Support

Php version 5.

white page

If you use php.exe, you may have a white page if you don't have in the first line of your php file a carriage return. Very strange …

<html><head><title>gerardnico.com</title></head>
      <body bgcolor="#FFFFFF">
        <h2>gerardnico.com</h2>
<B><?php echo 'Hello World'; ?></B>
      </body>
    </html>

Php-cgi return anything

Php-cgi.exe take a long time and don't return anything …

Difference between php and php-cgi

File hello_world.php in C:\php\

<?php phpinfo(); ?>

In a command dos

C:\PHP>php-cgi.exe hello_world.php
...........................
<p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
</p>
<p>If you did not receive a copy of the PHP license, or have any questions about PHP licensing, please contact [email protected].
</p>
</td></tr>
</table><br />
</div></body></html>
C:\PHP>
C:\PHP>

Now with php.exe

C:\PHP>php.exe hello_world.php
..............................
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

If you did not receive a copy of the PHP license, or have any
questions about PHP licensing, please contact [email protected].

C:\PHP>

Using PHP-Java Bridges with WebLogic Server

This is a free, open-source offering that wraps the Zend core engine. You can configure it to operate in the same way as the Zend Platform bridge shown above (that is, as a connection between an Apache/PHP configuration and a Java EE Server). This bridge also works in an additional configuration: It can be deployed as a Java servlet, as shown in Figure 2.

To install the SourceForge Java Bridge:

  1. Download a version from the SourceForge site. We used php-java-bridge_3.2.1_j2ee.zip for this tutorial.
  2. Open the zip file and extract JavaBridge.war.
  3. Explode JavaBridge.war into a new folder in an Eclipse workspace. (We called it “JavaBridge”.)
  4. Deploy the application to WebLogic Server.
  5. Point a Web browser at http://localhost:7001/JavaBridge. The index.php will present several example programs that demonstrate the bridge.

Running SourceForge Java Bridge as a PHP servlet

Php Servlet

In this configuration:

  1. The PHP request arrives and is mapped by WebLogic Server to the bridge's PHP servlet.
  2. The PHP script is passed to a php-cgi instance for processing.
  3. The bridge passes calls to Java objects into the WebLogic Server JVM through requests to its Java Gateway servlet.
  4. From there, access to JNDI resources happens in the usual way.

Helpful hints:

  • In the servlet configuration, by default, this bridge shells out a CGI process for each invocation of PHP, which terminates at the end of the request. In an environment where more than an occasional PHP request is run, this can lead to performance problems. The bridge distribution contains instructions for configuring FastCGI, which will maintain a pool of PHP address spaces and dispatch incoming requests to idle ones; this approach avoids the overhead of operating-system process initiation and termination for each request. The challenge involved in setting up this feature varies among operating-system platforms.

Reference





Discover More
Card Puncher Data Processing
Oracle Containers for J2EE (OC4J)

OC4J is a Java application server. It's composed with , so a lot of configuration for are the same for . This Java application server is a slimmed-down version of the better-known Oracle Application...



Share this page:
Follow us:
Task Runner