So I have chrooted MySQL into /opt/chroot/mysql, and everything runs fine. Apache is configured normally, and also runs fine.
I created a small PHP script which connects to the MySQL Daemon, and configured PHP so that the default socket used is the chrooted one. When SELinux is disabled, the script is able to connect fine. However, when SELinux is enabled, the script fails to connect (with error number 13), and the audit log tells me that SELinux denied the request.
Every tutorial I've found that deals with this problem tells me to disable SELinux. This is not what I want to do, so please don't suggest it! I want a solution that works whilst SELinux is enabled...I assume one must exist...
I'd guess that I probably have to change the SELinux contexts for the mysql files, but I'm not sure what to change them into to make it work.
UPDATE 2
You can build the custom SELinux policy module by following steps:
Refer to this topic for more details.
UPDATE
Run
semanage
command to add a context mapping for/opt/chroot/mysql/var/lib/mysql/
:And use
restorecon
command to apply this context mapping:If you are connecting via TCP/IP, try this: