Connect PHP linux to a database hosted on the windows (DB POSTGRESQL)?

0

I'm doing a project php in windows with a database engine POSTGRESQL , to test the correct operation I had to pass the project to linux (virutalbox~ubuntu) the problem is that I do not know how to connect to the database that is in windows while working with the project in linux.
I would appreciate the interest.

    
asked by JDavid 22.02.2017 в 14:37
source

1 answer

1

Assuming there is connectivity between the virtualized operating system and the physical PC, you have to review at least two DBMS files: the pg_hba.conf and postgres.conf . These files are hosted in the postgresql installation folder. The file postgres.sql is likely not to have to modify it because by default when installing the DBMS this listener on all interfaces that have installed the OS, but anyway it would be good to review and the directive listen_addresses put it pointing by example to the virtual interface that created the virtualization software; for example: listen_addresses = '192.168.1.100' assuming that is the ip of the interface that will communicate with your virtual system.

Now, the file pg_hba.conf is the configuration file of the server authentication, and in it you will have to add entries for the hosts that will have access to the databases of your server, being able to be an ip address or a range of ip addresses. In addition to establishing which database or databases customers will have access to. You must locate this section at the end of the document and establish entries for the PCs that will connect to your server, in this case the virtual system

host    all             all             127.0.0.1/32            md5
host    postgres,adjudicacion   all             192.168.1.102/32        md5

In this case it is specified that from the system where the DBMS is installed, all the DBMS users will have access to all the DBs using the md5 encryption and the second entry specifies that the PC with ip address 192.168.1.102 will have access to the database postgres and the database adjudicacion also making use of the% md5

It is recommended before making any changes to this file to keep a copy of the original to restore any failure. Once the changes are made, restart the DBMS so that they take effect.

    
answered by 22.02.2017 в 15:18