Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to setup a CentOS 5.5/64 bit VM to access a remote Oracle database with PHP and Perl scripts. (I have no experience with Oracle, have only programmed and administrated some PostgreSQl and MySQL before.)

I've installed the following Oracle Instant Client rpms:


And have added the following variables to my .bash_profile:

export TNS_ADMIN=/etc
export ORACLE_HOME=/usr/lib/oracle/11.2
export LD_LIBRARY_PATH=$ORACLE_HOME/client64/lib

Into the file /etc/tnsnames.ora I've written the infos received from the colleague at the remote site running the Oracle database:

some_string =
      (ADDRESS = (PROTOCOL = TCP)(HOST = my_address)(PORT = my_port))

The nice part is that I can connect from CLI now by running

sqlplus 'my_user/my_password@//my_address:my_port/PDTT'

and then can see some tables by issueing:

select table_name from user_tables;

And also I've run "sudo pecl install oci8" successfully, added the file /etc/php.d/oci8.ini containing:

and can see the following phpinfo() output:

Now my questions and problems please:

1) How should I setup ORACLE_SID variable and how to call sqlplus once it is set? Can/should I use ORACLE_SID from PHP and Perl scripts?

2) I run "sudo -E perl -MCPAN -e shell" and it works well when installing other Perl modules, but for "install DBD::Oracle" it fails with: Going to build T/TI/TIMB/DBD-Oracle-1.26.tar.gz

Using DBI 1.52 (for perl 5.008008 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI/

Configuring DBD::Oracle for perl 5.008008 on linux (x86_64-linux-thread-multi)

Remember to actually *READ* the README file! Especially if you have any problems.

  The ORACLE_HOME environment variable value (/usr/lib/oracle/11.2) is not valid.
  It must be set to hold the path to an Oracle installation directory
  on this machine (or a machine with a compatible architecture).
  For an Instant Client install, the directory should include an sdk subdirectory.
  See the appropriate README file for your OS for more information.
Running make test
  Make had some problems, maybe interrupted? Won't test
Running make install
  Make had some problems, maybe interrupted? Won't install

It mentions "sdk" dir above, but the rpm didn't have that dir at all:

# rpm -ql oracle-instantclient11.2-devel | grep -i sdk

Thank your for any hints and also any useful tips for Oracle installation and usage. There is lot of Oracle information out there, but it often assumes that Oracle is installed at the same machine.

Regards Alex

share|improve this question
I've submitted a bug report: – Alexander Farber Dec 6 '10 at 20:36
up vote 0 down vote accepted

For question #1, to access a remote database, ORACLE_SID is irrelevant. ORACLE_SID is only useful when the client and server are running on the same host. Given your tnsnames.ora file, you should be able to connect to the remote database using:

sqlplus my_user@some_string

you can also use

sqlplus my_user/my_password@some_string

However, I generally shy away from supplying passwords on the command line - snoopy users and the ps command can sometimes give it away. Let the database prompt you for the password. In fact, I have just gotten into the habit of issuing the sqlplus command thusly:

sqlplus /nolog

and then at the prompt issue

connect my_user/my_password@some_string

and nobody sees even the user or database you connect to, and I never have to think about it.

As for question #2, can't help you out.


Well, maybe I can help out on #2. I found this link on using DBD with instant client. Apparently you have to download/install the sdk instant client too. See step 3 in the link.

share|improve this answer

1) If you want to leave off the @connect_string you can set the TWO_TASK environment variable to the name tnsnames alias (in this case some_string).

The same is accomplished using the LOCAL variable on windows.

2) Sounds like sudo is reseting your environment variables. You will need to add $ORACLE_HOME and perhaps others to the env_keep line in your sudoers file. Other changes to the sudoers file that will acconplish the same thing are discussed here.

share|improve this answer
No, unfortunately sudo -E doesn't help (that was the command I'm actually using, had it wrong in my question first) – Alexander Farber Dec 6 '10 at 18:25
On looking closer it looks like $ORACLE_JOME is set. Is /usr/lib/oracle/11.2 the correct directory for your $ORACLE_HOME ? – Todd Pierce Dec 7 '10 at 8:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.