我正在运行一个使用 PostgreSQL 的 Django 应用程序。服务器正在运行带有 SELinux 的 RHEL 6.5。我遇到了 Django 应用程序无法连接到数据库的问题,我认为这是因为 SELinux 阻止了它。这是我在 Django 中看到的错误:
could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
我怎样才能解决这个问题?我遇到了这篇文章,但我不确定如何将解决方案 ( chcon -t postgresql_exec_t /path/to/pgbouncer
) 应用于我的问题。
谢谢!
[编辑]
这是/var/log/audit/audit.log
我尝试访问该站点时的样子:
type=AVC msg=audit(1396289984.549:9245): avc: denied { write } for pid=16975 comm="httpd" name=".s.PGSQL.5432" dev=sda1 ino=2359354 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:tmp_t:s0 tclass=sock_file
type=SYSCALL msg=audit(1396289984.549:9245): arch=c000003e syscall=42 success=no exit=-13 a0=10 a1=7fe625273aa0 a2=6e a3=0 items=0 ppid=16943 pid=16975 auid=22383 …
Run Code Online (Sandbox Code Playgroud)