Setting up a demo of PHP on Oracle Application Server 10g ---------------------------------------------------------- Since OracleAS 10g Release 2, Oracle has started building and shipping the PHP libraries. This means that the Oracle Http Server is PHP enabled and can run php scripts. This article demonstrates that capability along with a small set of demonstration scripts. Demo Installation/Deployment As with most PHP, installation and deployment of a PHP script is pretty much the same thing. You simply copy the script(s) to the appropriate Oracle Http Server DocumentRoot directory. The default is /Apache/Apache/htdocs, though this may vary if you have configured virtual hosting or have otherwise reconfigured Oracle Http Server. To enable the .phps extensions that allow you to view the source code to the php pages, you should add the following two lines to your /Apache/Apache/conf/httpd.conf file: RewriteEngine on RewriteRule (.*)\.phps$ $1.php [T=application/x-httpd-php-source] This adds a mod_rewrite rewriting rule that returns the php source for a php file, when it is queried with a .phps extension. This is a very insecure feature, and should NOT be enabled on a production application server. To access the demo, you should visit /phpdemo/phpentry.php in a web browser. This screen shows the classic “phpinfo()” output. You can examine this information at your leisure to inspect the PHP environment provided by Oracle. The source is accessible (assuming you have enabled the .phps extension as above) via a link in your browser. One of the key features you should note is that we build with the oci8 PHP extension library—which allows a PHP script to access an Oracle Database. There is a link to the DB part of this demo which you should follow now. This screen is simply a data gathering screen for information about your database connection. You can either put a simple TNS name entry in, or you can put a full tns description in. If you decide to put a simple TNS name in, that TNS name needs to resolve via the tnsnames.ora file located in /network/admin. You will need to refer to the database documentation for a valid entry here (note that one may already be created for your infrastructure database, if you have one). The DB demo uses the well-known scott/tiger schema, though this is not necessarily available. Follow the setup link for instructions that will enable a “demo” scott/tiger schema. Once you submit a tns name, you will go to the query page, which demonstrates accessing the database from a PHP page. It simply connects, retrieves the data, and then displays it in a table. The source is available via a link.