httpd cannot connect to postgresql

akhirnya setelah seharian mengotak atik postgresql + php, dimana php nya gak mau connect ke postgresqlnya
dan mendapatkan pesen di /var/log/audit/audit.log
dalam hal ini connect dari command line berhasil akan tetapi dari php gak bisa alias httpd cannt
type=AVC msg=audit(1124098046.103:2735300): avc: denied { name_connect } for pid=12013 comm=”httpd” dest=5432 scontext=root:system_r:httpd_t tcontext=system_u:object_r:postgresql_port_t tclass=tcp_socke
setelah mencari seharian di google.com dan tidak ketemu, ya akhirnya tanya ke pak bos deh

caranya :

[[email protected] ~]# sestatus | grep httpd
allow_httpd_anon_write            inactive
allow_httpd_sys_script_anon_write inactive
httpd_builtin_scripting           active
httpd_can_network_connect         inactive
httpd_disable_trans               inactive
httpd_enable_cgi                  active
httpd_enable_homedirs             active
httpd_ssi_exec                    active
httpd_suexec_disable_trans        inactive
httpd_tty_comm                    inactive
httpd_unified                     active
[[email protected] ~]# sestatus | grep postgr
postgresql_disable_trans          inactive
[[email protected] ~]# sestatus | grep sql
mysqld_disable_trans              inactive
postgresql_disable_trans          inactive
[[email protected] ~]#


nah disitu kelihat bahwa :
httpd_can_network_connect inactive

yang aku lakukan adalah :

[[email protected] ~]# rpm -q -l php | restorecon -R -v -f -
[[email protected] ~]# rpm -q -l php-pgsql | restorecon -R -v -f -
[[email protected] ~]# rpm -q -l postgresql | restorecon -R -v -f -
[[email protected] ~]# rpm -q -l postgresql-server | restorecon -R -v -f -
[[email protected] ~]# rpm -q -l httpd | restorecon -R -v -f -
[[email protected] ~]# rpm -q -l postgresql-libs | restorecon -R -v -f -
[[email protected] ~]# setsebool httpd_can_network_connect=1
[[email protected] ~]# sestatus | grep httpd_can_network_connect
httpd_can_network_connect         active
[[email protected] ~]#	
[[email protected] ~]# /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
[[email protected] ~]# /etc/init.d/postgresql restart
Stopping postgresql service:                               [  OK  ]
Starting postgresql service:                               [  OK  ]
[[email protected] ~]#

selesai sudah 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *