Running Oracle 10g XE & PHP on Linux
November 15th, 2005
I decided to reformat my local webserver the other day. This server generally runs all my code on it before its published onto the web. I was using Fedora Core 4 Test 3, but decided to lose some stuff I've installed on there, and put a full release of FC4 on.
I settled on the following LAMP options:
I decided that I'd stick Oracle XE on as well, and have a play with that. Surely if MySQL is that simple to install then Oracle can't be that much harder! Or so I thought...
Heading over to the Oracle XE home page allows you to download the Oracle DB System. Here's what I did from then on to get this baby installed:
- Installing Oracle
I grabbed the RPM version, weighing in at a hefty 200Mb, and installed it.rpm -ivh oracle-xe-10.2.0.1-0.1.i386.rpmAt this point, it was kindly noted out that I needed the libaio libraries as well:
yum install libaiowill sort out that dependancy. If you don't have yum installed and configured, then you can install the RPM directly.Re-run the RPM installation line, and follow the onscreen instructions.
-
Following the Getting Started Guide assumes you are installing on either Windows, or using a GUI such as KDE on Linux. If you are installing remotely as I was, then ignore the first step of that guide, and instead point your web browser to http://Your_Server:8080/htmldb. Make sure that you have opened port 8080 on your server's firewall (You do have a firewall running don't you?!)
You should get a nice login screen where you can continue the Getting Started Guide
- Compiling Oracle Support into PHP
Next step you need to take is to compile the Oracle extension into PHP. Grab the latest source for PHP and start the installation:
tar -zxf php-5.0.5.tar.gz
cd php-5.0.5
./configure
--with-apxs2=/usr/local/apache/bin/apxs
--with-oci8=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
--with-oci8-instant-client=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/Of course, add other modules as you see fit. Once the configure routine has completed, its time to make and install. Note that you may need to copy php.ini into /etc as well:
make
make install
cp php.ini-dist /etc/You'll also need to add the PHP Handlers to your apache configuration file
httpd.conf:
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phpsRestart Apache and test if Oracle support is working by creating a phpinfo page and verifying the contents under the oci8 heading:
- Environment Variables
The next step to getting Oracle working is to setup the environment variables. The quickest way to do this is to edit your rc.local file to add these in before starting apache. Adding these to the Apache httpd.conf file using SetEnv didn't work, and other users have reported similar problems. Here's what I'm using in my /etc/rc.d/rc.local file
ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/
ORACLE_SID=XE
export ORACLE_HOME ORACLE_SID
export LD_LIBRARY_PATH=${ORACLE_HOME}/lib:${LD_LIBRARY_PATH}
/usr/local/apache/bin/apachectl startThis will make sure that your environment variables are setup before starting apache - this is essential, else apache won't pick them up. (Make sure you set your path to apachectl correctly).
This does however have one assumption. That is, that apache wasn't installed via RPM, but instead from source. Installing from RPM tends to stick httpd in the chkconfig to run at levels 3, 4, and 5. You could simply remove this:
chkconfig --level 345 httpd offor simply add
service httpd stopbefore the Oracle information for rc.local.
- Testing it out
The final step is to test it out. If you have completed the getting started guide, then you would have unlocked the HR user, which we'll use to login and grab some data:PHP:
This should give you a printout of 5 employees from that table.
- Congratulations, you've managed to install Oracle support for PHP.
Some other useful links:
Add to del.icio.us
Digg this
Technorati
Related Posts:
- Oracle XE and libaio
- Google Earth for Mac OS X
- Installing PECL Modules
- MySQL Events
- Problems with simple templating
Entry Filed under: PHP
1 Comment Add your own
1. pushkin | January 18th, 2007 at 12:58 pm
I'm having a little problem with my remote Oracle installation. I am using SSH/PuTTY to connect and manipulate my server, but my server is an actually Virtual Server - it is running on freevps and has only 85 Mb of RAM and unlimited SWAP
Is there a way to overcome 256 Mb limitation for Oracle XE installation?
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed