Search code examples
linuxapacheselinux

How should I set up SELinux to allow my apache to remotely access postgresql?


This is my database RiceLncPedia. When I do not change SElinux (enabled by default), some pages that require remote posgresql will appear Permission denied (such as this). When I turn off SElinux using sudo setenforce 0, these pages can all be Normal visit.

But for the sake of security, I want to meet the normal access of the database without closing SElinux. Do I need to change anything?

my system:

[yxu@localhost js]$ cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

Solution

  • You need to allow apache to access to your DB:

    setsebool httpd_can_network_connect_db 1