Configuring Oracle Database XE and PHP

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

Configuring Oracle and PHP

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 file php.ini you 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:

;extension=oci8.so

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 have oci8.so in 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-oci8 option.

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:

/etc/init.d/httpd restart

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

{mospagebreak title=Performing Post-Installation Tasks}

By default, Apache and Oracle Database XE start automatically when Windows or Linux starts. If you did not launch the administrative interface when you finished the installation steps, open your Web browser and navigate to this URL: http://localhost:8080/apex/ .

To access the administrative interface from another workstation (even if you did not install the client software on that workstation), use the same URL with the name of the Oracle Database XE server hostname instead of the default internal Linux hostname localhost , as in this example: http://example.com:8080/apex/ .

If Oracle Database XE’s Web service has started successfully, you will see the login screen shown in Figure 27-7.


Figure 27-7.  Oracle Database XE login page

Creating User Accounts

In a default installation of Oracle Database XE, you specify the password for both the SYS and SYSTEM accounts. Following Oracle best practices, you should rarely use the SYS account, since it is the owner of all internal database tables and you want to minimize the risk of deleting or changing these tables. While you can use the SYSTEM account for most, if not all, of your administrative tasks, you should create another privileged account. This has a number of advantages. First, in case you lose, forget, or misplace the password for one of the accounts, you can still easily get into the database with another account. Second, in an environment with more than one administrator, having a separate account for each administrator provides more accountability and the option to fine-tune the privileges granted to each administrator.

To create an additional administrator account, log in using the Oracle Database XE administration home page shown in Figure 27-7, and click Administration. On the next page, click Database Users. Alternatively, you can click the arrow next to the Administration button itself and follow the drop-down menus to the user account management page.

Next, click the Create button and you will see the Web page shown in Figure 27-8.


Figure 27-8.  Oracle Database XE Create Database User page

Specify a username and the password. By default, the CONNECT and RESOURCE roles are selected. To give this user administrative privileges, select the DBA checkbox as well. We will explain how privileges and roles work in Chapter 30. Click the Create button, and you are ready to use the new administrative account the next time you log in.

Summary

You should now have a complete application and database environment installed: Oracle, PHP, and Apache on either Windows or Linux. Oracle Database XE retains many of the robust features found in the other (i.e., not free) versions of Oracle. It integrates nicely with other open source products such as PHP and Apache.

Throughout the rest of this book, we’ll use examples in the Windows environment except where the difference between environments is significant. However, you will soon find that you won’t even be able to tell that you’re on either Windows or Linux. This provides you with the flexibility to move your applications between platforms when the need arises with minimal, if any, rework.

The next chapter introduces many more administrative functions you will perform on a regular basis. We’ll also show you the basics of Oracle Database XE’s memory and disk architecture to help you optimize your database environment, whether it’s just for development or for a mission-critical department application. 

[gp-comments width="770" linklove="off" ]
antalya escort bayan antalya escort bayan