In this conclusion to a five-part article series on installing and configuring Oracle Database XE, you will learn how to enable PHP to connect to the Oracle 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 you have all of the required components for your OPAL installed, you must perform the final hookup: enabling PHP to connect to the Oracle database.
Locate the PHP configuration filephp.iniyou created in Chapter 2. In a default installation on Red Hat Enterprise Linux 4, it is located in/etc/php.ini. Open the file in your favorite text editor and locate this line in the file:
Remove the semicolon at the beginning of the line and save the file in its original location. If you are not using Zend Core for Oracle on your Linux server, you automatically have OCI8 configured. If you do not even haveoci8.soin your extensions directory, you can get it as a PEAR module using the following command:
pear download oci8
Next, you must reconfigure PHP with the--with-oci8option.
For these changes to take effect, you must restart the Apache HTTP server. The easiest way to do this in Linux is to run this command:
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.0 or 2.2 installation on Red Hat Linux, the document root directory is/var/www/html.
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 the URLhttp://localhost/test_ora_conn.php, and you should see the success message in the firstprintstatement.