Last active
April 14, 2018 01:03
-
-
Save virbo/fc89650bf0bd5f92f4096891ae6089a6 to your computer and use it in GitHub Desktop.
Step by step configuration postgres form remote open (Server Centos 7)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Path to pgsql config: /var/lib/pgsql/data | |
PART 1 (edit postgresql.conf) | |
1. Edit postgresql.conf where | |
#listen_addresses = 'localhost' | |
change to | |
listen_addresses = '*' | |
2. Edit postgresql.conf where | |
#port = 5432 | |
change to | |
port = 5432 | |
as you can see if sign # it means that is not inclouded in directive. If we remove the sign # the directive is set. | |
3. Edit postgresql.conf where | |
#max_connections = 32 (no. 32 can be diferent) | |
change to | |
max_connections = 32 (yu can set no 32 or any other as you wish) | |
4. Close and save postgresql.conf | |
PART 2 (edit pg_hba.conf) | |
1.Edit pg_hba.conf where | |
# IPv4 local connections: | |
under that line add | |
host database_name all 2xx.xx.xx.xx/24 md5 (where 2xx.xx... it means put the IP for wich you whant to allow remote access). Line # IPv4 local connections: can be found at the bottom of the pg_hba.conf file. | |
2. Close and save pg_hba.conf | |
3. If you did everything right your pg_hba.conf file at the bottom should look something like this: | |
# TYPE DATABASE USER CIDR-ADDRESS METHOD | |
# "local" is for Unix domain socket connections only | |
local all all ident sameuser | |
# IPv4 local connections: | |
host all all 127.0.0.1/32 ident sameuser | |
host database_name all 2xx.xx.xx.xx/24 md5 | |
# IPv6 local connections: | |
host all all ::1/128 ident sameuser | |
PART 3 | |
1. Restart Postgresql server. You can do it through WHM or use SSH command | |
service postgresql restart | |
2. If adding new data base you will need to add remote access permission for it. Use tutorial from PART 2, point 1. and restart postgresql server. | |
3. Of course, you need to open port 5432 in your firewall or nothing will work. | |
THE END | |
Source: https://forums.cpanel.net/threads/postgresql-remote-access.51069/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment