Need to disable SELinux on web
sourcedelica opened this issue · comments
I spent a boatload of time trying to figure out why my web page couldn't connect to the DB.
First I realized that I needed to use an IP address in both the Mysql user permissions and the mysqli_connect
call.
But it was still giving me this error on the web page.
2003:Can't connect to MySQL server on '192.168.86.54' (13)
I tried installing MySQL on the web server and was able to connect using the mysql
client.
Finally I found this Stackoverflow article which said to set
setsebool -P httpd_can_network_connect_db=1
That worked. I ended up using this in my playbook.
- selinux:
state: disabled
The below command did the trick for me. Reference stackoverflow
sudo setsebool -P httpd_can_network_connect 1
I spent a lot of time debugging this too, here is the setsebool
command as a task:
- name: Allow httpd to connect to DB over the network
seboolean:
name: httpd_can_network_connect
state: true
persistent: true
become: true