• 4

The Beginning

Server 1 is my CentOS 7 production server. It contains Apache, ssh and a Postgresql database.

Server 2 is my CentOS 7 test server. It contains Apache, ssh and a test database.

Both servers are set with firewalld to accept 22, 80 and 443. Both servers have the following setting.

sudo setsebool httpd_can_network_connect_db 1 ...

How do I know these ports are open?

I can ssh in (port 22). I can see the "Testing 1, 2, 3..." test page via http and https (port 80 and 443). I can access Postgresql by using SQL Maestro, DBeaver, DBSchema, etc. (port 5432).

...The Problem

I can access Postgresql on Server 1 using DbSchema, HeidiSQL, Postgresql SQL Maestro, etc, remotely, from anywhere. However, I cannot connect from Server 2 using PHP and PDO. It always leads to [08006] Timeout.

I tried the following, but did not help; sudo setsebool httpd_can_network_connect 1

The Question

How do I access Postgresql db on Server 1 from Server 2 using PHP? I'm new to CentOS7. I have done this before using other Linux distro with no issues. What SELinux/other settings that I missing? ...

The Solution (below)

See Alexander's answer below. I thought the 5432 was enabled in firewall-cmd. When I issued the following command

sudo firewall-cmd --zone=public --list-services

only dhcpv6-client http ssh https were listed! What happened to my postgresql? I simply issued the following to make the service permanent;

sudo firewall-cmd --add-service=postgresql --permanent

Check which package is installed (which provider) and provides the stack, then use the same namespace.

  • Webtatic uses php56w-*
  • IUS uses php56u-*
  • remi-safe (SCL packages) use php56-php-*
  • remi-php56 simply use php-*
  • other providers can use something else

As you need pdo_mysql driver, simply

yum install <namespace>-pdo_mysql

(using the ext name, yum will find the correct package name which provides this ext).

Also check you don't have any "exclude" lines in the yum configuration (such as the ones provided in altered cpanel distributions)

  • 1
Reply Report

Hi everybody! Our today's article is on PostgreSQL with phpPgAdmin installation setup on CentOS 7. PostgreSQL is one of the major and important open-source relational database management systems that have helped to shape the world of application development with advanced, SQL-compliant. The main advantage with using PostgreSQL is that it requires very minimum maintenance efforts because of its stability and the applications based on PostgreSQL has low cost of ownership in comparison with other database management systems. Its designed to be extensible in a way that you can define your own data types, index types, functional languages, etc.

Managing databases using individual SQL statements is a difficult task , so in this article we will also show you one of the best and most popular graphical user interface for managing a PostgreSQL database, that is phpPgAdmin.

PhpPgAdmin is a web-based GUI application that makes it simple for administering your PostgreSQL databases. phpPgAdmin will let you add, remove and manage databases, tables, and entries; run specific SQL queries, backup the database, search and import record, and much more.

  • 1
Reply Report

As you mentioned in you question, you have opened only three ports in firewalld. You should open port 5432 on firewall.

Also you should check on which IP listening postgres, it could listening only on

  • 1
Reply Report