SELinux and PHP Database Connection

Since I’m using Bacula for my Backups, I wanted to install a nice Web interface to view my Jobs, Volumes, generate reports and such. I thought I’d give a try at Bacula-Web, since the installation is really simple.

Bacula-Web configuration is really simple, all you have to do is edit the “config.php” file to point the database connection to the same database that Bacula uses and your good to go. Once I’d done that, I opened the Bacula-Web page, and the following error appeared:

Database error

Message: SQLSTATE[08006] [7] could not connect to server: Permission denied Is the server running on host "ptipgsql.pti" and accepting TCP/IP connections on port 5432?

Well, I was SURE that the server/database/username/password was correct, because connection from the command line (using psql) worked just fine. After a LOT of Googling, I found out that there was a Boolean in SELinux specific to allow the Web Server to connect to remote hosts.

So, all I had to do is run as root:

# setsebool -P httpd_can_network_connect on

And Bacula-Web worked just fine. Lesson learned: always check the /var/log/audit/audit.log file on access denied errors!!!!!

Advertisements

Tags: , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: