I've finished configuring a Vagrant box with oracle 11G.
I've tested the connection using SqlDeveloper from my local MAC machine and all seems fine (ssm_android -> localhost 1521 xe)
.
What I really need is to connect to this Oracle DB through PHP.
Here's my Vagrant config for the oracle machine (I added some relevant info below):
vagrant@oracle:/u01/app/oracle/product/11.2.0/xe/network/admin$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0/xe
vagrant@oracle:/u01/app/oracle/product/11.2.0/xe/network/admin$ echo $ORACLE_SID
XE
vagrant@oracle:/u01/app/oracle/product/11.2.0/xe/network/admin$ vi listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/xe)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)
vagrant@oracle:/u01/app/oracle/product/11.2.0/xe/network/admin$ vi tnsnames.ora
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
vagrant@oracle:/u01/app/oracle/product/11.2.0/xe/network/admin$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 16-FEB-2015 13:26:37
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date 16-FEB-2015 11:34:27
Uptime 0 days 1 hr. 52 min. 10 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Default Service XE
Listener Parameter File /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/oracle/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "XE" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
Service "XEXDB" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
The command completed successfully
And here's the error i get in PHP when I try connecting using the following data
user = "ssm_android"
host = "127.0.0.1:1521/XE"
password = "xxxxxxx"
database = "XE"
:
Fatal error: Uncaught exception 'Exception' with message 'Cannot connect to database: ORA-12541: TNS:no listener' in /var/www/core/db.class.php:164 Stack trace: #0 /var/www/core/db.class.php(113): Db->connect('ssm_android', 'NtakmdVSYgsYSNii11...', '127.0.0.1:1521/...') #1 /var/www/index.php(56): Db->__construct() #2 {main} thrown in /var/www/core/db.class.php on line 164
Could be relevant the fact that the machine running the php is another local Vagrant machine mapped to localhost... not sure..
I'd appreciate any insight on this.
Thanks.