Thursday, July 8, 2010

Oracle installation Ubuntu Lucid 10.04

Download and install the oracle client using runtime option
execute the .sh commands as root at the end of the installation
compile your php using your new oracle path mine was



./configure ..removed other options... --with-oci8=/opt/oracle11g/product/11.1.0/client_1



edit your root user paths mine was this



sudo cat /root/.bashrc

alias ls='ls --color=auto -hF'
alias ll='ls --color=auto -lhF'
alias la='ls --color=auto -lahF'
alias grep='grep --color=auto'
EDITOR=vim
export ORACLE_BASE=/opt/oracle11g/product/11.1.0
export ORACLE_HOME=/opt/oracle11g/product/11.1.0/client_1
export ORACLE_SID=mavid.dev
export ORACLE_OWNER=jason
export ORACLE_TERM=xterm
export THREADS_FLAG=native
#export ORA_NLS=AMERICAN
export ORA_NLS33=$ORACLE_HOME/nls/data
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=/usr/local/apache/bin:$PATH:$HOME/bin


Open a new terminal to allow bashrc to reload config settings

now start the apache server as root


/usr/local/apache/bin/apachectl start



now run this php script in your web browser to test it




echo "ORACLE_HOME=".getenv("ORACLE_HOME");

$con = oci_pconnect ( "oracleusername", "mypassword", "mydevbox" ) or die("Oracle connection failed. ");


if (!$con) {
$e = oci_error(); // For oci_connect errors pass no handle
echo "ORACLE ERROR: ".htmlentities($e['message']),"err";
}


?>


If your oracle home is blank then your bashrc is not being set before apache starts

also make sure you created the tnsnames.ora file for oracle connections in this directory


/opt/oracle11g/product/11.1.0/client_1/network/admin/tnsnames.ora


the content should be

mydevbox =
(DESCRIPTION =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = 192.168.1.45)
(PORT = 1521)
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = simpleDEVBox)
)
)

No comments:

Post a Comment

Got a Suggestion please let us know