Installing Oracle Database XE on the Windows Platform

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).

Performing the Installation

Double-click the file OracleXE.exe, and the Oracle Install Wizard for Oracle Database XE starts. You will see the window shown in Figure 27-1.

Click the Next button, and you will see the License Agreement page for Oracle Database XE shown in Figure 27-2. Review the license agreement and click the I Accept… radio button, then click the Next button. Oracle Database XE is free, if you weren’t aware of this yet.


Figure 27-1.  The Oracle Database XE Install Wizard


Figure 27-2.  The Oracle Database XE License Agreement window

In Figure 27-3, select the folder where you want to install Oracle Database XE. Be sure to select a folder on a disk drive with at least 1.6GB of available disk space. In this example, you put the installation files and the starter database in the folder D:OracleXE . By default, the system executable and configuration files reside in the app subdirectory, and user data files are stored in the oradata subdirectory under D:OracleXE ; however, you can change the location of the data files later if you have a faster disk drive, for example.


Figure 27-3.  Specifying the Oracle Database XE destination location

After you click the Next button, you enter and confirm the password for the SYS and SYSTEM accounts shown in Figure 27-4. You can create different passwords for these accounts later using the administrative Web page we introduce later in the “Creating User Accounts” section. Click the Next button after you confirm the password.


Figure 27-4. The Oracle Database XE Specify Database Passwords window

In the installation settings window shown in Figure 27-5, you can review the options you specify, including the default values for the Oracle database listener, Oracle Services for Microsoft Transaction Server, and the Oracle administrative HTTP listener port.


Figure 27-5.  The Oracle Database XE installation settings window


Note  You may wonder why the default HTTP listener port is 8080 and not the default HTTP port 80. This is because the default installation of Apache HTTP Server uses port 80; any content you serve for your users will most likely be managed by Apache and your PHP applications using port 80. Since the Oracle Database XE administrative interface is also an HTTP service, it must use a different port number. As a result, you have two Web servers running on your workstation at the same time. This is not a problem since they are listening on different port numbers.


After you click the Install button, the installer copies the files to the destination directory and creates the database. When the installation process is complete, you see the window shown in Figure 27-6.


Figure 27-6.  Oracle Database XE installation is complete.

By default, the Launch the Database Homepage checkbox is selected. After you click the Finish button, the installer automatically starts the Oracle Database XE administrative interface you saw in Chapter 25.

{mospagebreak title=Configuring Oracle and PHP}

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 file php.ini you created in Chapter 2 and locate this line in the file:

;extension=php_oci8.dll

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 parameter extension_dir in php.ini ; its value is the directory where PHP finds its extensions. For this particular PHP installation, here is the value of extension_dir :

extension_dir = "c:php5.2.0ext"

If the file php_oci8.dll is not in the directory referenced by the parameter extension_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 file test_ora_conn.php using 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 is C:Program FilesApache Software FoundationApache2.2 htdocs . If you followed the Apache installation instructions in Chapter 2, the document root directory is C:Apache2htdocs .

Listing 27-1. PHP Code to Test Oracle Connectivity (test_ora_conn.php)

<?php
if ($conn = oci_connect(‘system’, ‘yourpassword’, ‘//localhost/xe’)) {
   
print ‘Successfully connected to Oracle Database XE!’;
   
oci_close($conn);
} else {
   
$errmsg = oci_error();
   
print ‘Oracle connect error: ‘ . $errmsg['message'];
}
?>

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 the else clause of the if statement in the PHP code. Navigate to this URL http://localhost/test_ora_conn.php , and you should see the success message in the first print statement.

You’ve probably seen the Oracle-specific function calls such as oci_connect and oci_error in 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.

Google+ Comments

Google+ Comments