Nu10 -
Joined: 13 Jan 2009 Posts: 2
|
Posted: Fri Jan 16, 2009 2:05 pm Post subject: Oracle 10g XE-Abyss X1-PHP5. Works like a charm! |
|
|
New user wanting to contribute... there are a lot of references to MySQL but for school reasons I have to use Oracle.
Audience
1. Students needing to practice on Oracle 10g
2. Professionals wanting a lightweight web server development environment for Oracle-PHP.
My Sandbox
OS: Windows XP Pro
Web server: Abyss X1
Database: Oracle 10g Express Edition
Script: Aprelium's PHP v5.2.8 package
Ram: 2GB
HDD: 300GB
Resources & Credits
AbyssUnderground
Oracle
Aprelium
Instructions Overview
A. Install Oracle XE
B. Install Abyss
C. Install PHP
D. Edit 'php.ini'
E. Test Oracle DB
A) Install Oracle XE
1. Obtain Oracle 10g XE and its documentation from Oracle
(it is free and suitable for a student's needs).
http://www.oracle.com/technology/products/database/xe/index.html
2. Obtain Abyss X1 v 2.5 from Aprelium's website
3. Obtain PHP v5.2.8 from Aprelium's website.
I used the PHP v5.2.8 configured by Aprelium for Windows.
4. Install Oracle XE as per Installation Guide B25143.
http://www.oracle.com/pls/xe102/homepage
> I installed XE Server only (I ignored the references to XE clients)
> Make note of your user id and password because you need it to log in to the database
> The installation program installs the GUI interface (i.e. Application Express) by default.
> I did not upgrade Application Express to the newest version because I do not need it and I don't want the headache.
> a sample Human Resources database is intalled by default.
5. Go to XE's Login Page
Section 6 of Guide B25143 provides 2 methods to get to the database login page:
i) Start->All Programs->Oracle XE->Goto to Homepage
ii) Open Internet Explorer and type the address: "http://127.0.0.1:8080/apex/" and press GO
6. Login to the XE database using the user id and password you created on the installation process.
The homepage will have 4 boxes: i) Administration, ii) Object Browser, iii) SQL, iv) Utilities.
7. Select the Administration box.
You will see 5 boxes: i) Storage, ii) Memory, iii) Database Users, iv) Monitor, v) About Database
8. Select Database Users
> you will now be at: Home->Administration->Manage Database Users
> there will be 1 box: HR
9. Select the HR user group... we will make 2 changes to this user
> your username is unchanged as "HR".
> i) create a password... and make note of it
> ii) change the Account Status to "UNLOCKED".
10. Update the configuration changes by clicking "Alter User" button.
11. Logout of the XE database
B) Install Abyss X1
Use the tutorial by Abyssunderground.
http://www.abyssunderground.co.uk/installing-abyss.php
> I made no changes on the install of Abyss X1.
C) Install PHP 5.2.8
Aprelium has prepared a PHP version specially configured for Abyss and Windows... I used Aprelium's PHP version.
http://www.aprelium.com/abyssws/php5win.html
Use Abyssunderground's PHP installation tutorial as follows:
http://www.abyssunderground.co.uk/installing-php.php
Step 1: ignore this step because we are using Oracle XE and Aprelium's PHP
Step 2: install as described in the tutorial except for item 5:
On item 5, use "php-cgi.exe" because we are using v5 of PHP
Step 3: test php as described in the tutorial (remember to save your php scripts in the htdocs folder).
D) Edit PHP.INI
The Aprelium PHP install did not enable the Oracle extension by default; therefore, we have to edit the .ini file to enable the extension for Oracle.
Change
From: ;extension=php_oci8.dll
To: extension=php_oci8.dll
The reference article for this instruction is here:
http://www.oracle.com/technology/tech/php/htdocs/inst_php_apache_windows.html
E) Test Oracle DB
This step is necessary to test if we can access XE's demo HR database via Abyss-PHP.
The Oracle article mentioned above provided the test php script.... there is no change.
In Step 9 of the Oracle install, above, we created a password for the HR user and we unlocked the account status. The reason we did that was because of the following script... you need to edit the script for your password.
The demo user ID is 'HR' by default... on line 3 of the script, I have edited the script for you.
For password on line 3 of the script, you need to change "YOUR_PASSWORD" to whatever your real password is.
Everything else remains unchanged.
<?php
$db_conn = ocilogon("HR","YOUR_PASSWORD","//127.0.0.1/XE");
$cmdstr = "select last_name, salary from employees";
$parsed = ociparse($db_conn,$cmdstr);
ociexecute($parsed);
$nrows = ocifetchstatement($parsed,$results);
echo "<html><head><title>Oracle PHP Test</title></head><body>";
echo "<center><h2>Oracle PHP Test</h2><br>";
echo "<table border=1 cellspacing='0' width='50%'>\n<tr>\n";
echo "<td><b>Name</b></td>\n<td><b>Salary</b></td>\n</tr>\n";
for ($i=0; $i < $nrows; $i++)
{
echo "<tr>\n";
echo "<td>".$results["LAST_NAME"][$i]."</td>";
echo "<td>$".number_format($results["SALARY"][$i],2)."</td>";
echo "</tr>\n";
}
echo "<tr><td colspan='2'>Number of Rows:$nrows</td></tr></table>";
echo "<br><em>If you see data, then it works!</em><br></center></body></html>\n";
?>
When you run this script you will see a table of names and salaries.We're done.
PostScript suggestions:
1. Aprelium could edit the php.ini file to enable Oracle extension by default.
2. Abyssunderground could create and host a tutorial for Abyss-PHP-Oracle 10g XE.
3. Someone could try Abyss with Microsoft SQL Server 2005 Express Edition and create a tutorial.
Microsoft provides a free, lite, version of SQL Server 2005.
http://www.microsoft.com/Sqlserver/2005/en/us/express.aspx
http://www.snapfiles.com/Freeware/webpublish/fwdbquery.html
4.FYI: there are freeware DB Managers from Navicat and EMS for Oracle XE and MSSQL 2005 XE.
http://www.navicat.com/
http://sqlmanager.net/
5. For help on using the Oracle PHP extension: oci8.dll
http://www.oracle.com/technology/tech/php/index.html
Bye |
|