HomeOracle Page 2 - Installing Oracle Database XE on the Windows Platform
Configuring Oracle and PHP - Oracle
In this second part of a five-part article series on installing Oracle Database XE, you'll learn how to install the database on the Windows platform, and enable PHP to connect to the database. This article is excerpted from chapter 27 of the book Beginning PHP and Oracle: From Novice to Professional, written by W. Jason Gilmore and Bob Bryla (Apress; ISBN: 1590597702).
Now that we have all of the required components for our Apache/PHP/Oracle on Windows environment installed, you must perform the final hookup: enabling PHP to connect to the Oracle database.
Find the PHP configuration filephp.iniyou created in Chapter 2 and locate this line in the file:
Remove the semicolon at the beginning of the line and save the file in its original location. Be sure to check the value of the parameterextension_dirinphp.ini; its value is the directory where PHP finds its extensions. For this particular PHP installation, here is the value ofextension_dir:
extension_dir = "c:\php5.2.0\ext"
If the filephp_oci8.dllis not in the directory referenced by the parameterextension_dir(along with about 45 other extensions), locate it and change the value of this parameter to the directory containing it. For these changes to take effect, you must restart the Apache HTTP server. The easiest way to do this in Windows is to use the Start menu. Click All Programs ? Apache HTTP Server ? Control Apache Server ? Restart. Unless an error occurs, you will briefly see a command window. To see if PHP can connect to Oracle successfully, create the filetest_ora_conn.phpusing the code in Listing 27-1 and place it in your Apache document root. For a default Apache 2.2 installation on Windows, the document root directory isC:\Program Files\Apache Software Foundation\Apache2.2\ htdocs. If you followed the Apache installation instructions in Chapter 2, the document root directory isC:\Apache2\htdocs.
Listing 27-1. PHP Code to Test Oracle Connectivity (test_ora_conn.php)
Be sure to substitute the password you entered in the step shown in Figure 27-4 in the second line of the script; otherwise you will exercise theelseclause of theifstatement in the PHP code. Navigate to this URLhttp://localhost/test_ora_conn.php, and you should see the success message in the firstprintstatement.
You’ve probably seen the Oracle-specific function calls such asoci_connectandoci_errorin examples earlier in this book. We’ll talk about them more formally in Chapter 28 and throughout the examples in the rest of the book.
Please check back next week for the continuation of this article.