I have a Ubuntu machine and I have a Linux instance running in a Virtual-box on this machine. I need to connect to the oracle instance (through the oracle extension in php) . The extension is running. I am not sure about how to do the port forwarding and if I need to edit the host file. I read the manual, but still no luck. Any help is appreciated. Thanks
Oracle process listens by default to requests on port 1521.
Note : this solution needs only to be set up if you VM network is configured as NAT.
The simplest solution if no process on your host is using port 1521 is to redirect port 1521 on your host to port 1521 on your guest Oracle VM (you can choose another port on host but then you will probably need to do a bit more configuration on php side but I do not know this part.
To achieve port redirection, if you have a recent version of VirtualBox, go to your VM configuration using the GUI, Select section Network, click on the tab corresponding to your network card, click on the button at the bottom named "Port redirection" and fill values using the values described above. For the IP adresses, use 127.0.0.1 for both.
For more information on port forwarding and documentation on how to setup it with command line you can read Virtualbox manual section here : https://www.virtualbox.org/manual/ch06.html#natforward