Symptoms
-
A PHP forum application shows an error similar to the following after a content migration to a new server:
An unexpected database error occurred. Please try again later.
-
SELinux errors can be found in
/var/log/plesk/panel.log
:SELinux is preventing /opt/plesk/php/8.2/sbin/php-fpm from connect to access on the unix_stream_socket /var/lib/mysql/mysql.sock. For complete SELinux messages run: sealert -l 4351bc75-4efb-407b-8cbb-aa0878113737
-
There are messages referring to denied permissions in Domains > example.com > Dashboard > Logs, but when checked, CHMOD permissions are correct. For example:
An exception occurred: [XF\Db\Exception] Permission denied in src/XF/Db/Mysqli/Adapter.php
-
Disabling SELinux enforcing makes the PHP forum work again.
# setenforce 0
Cause
SELinux is preventing PHP-FPM access to the MySQL socket.
Resolution
Create the SELinux rule to allow the PHP-FPM services to connect to the MySQL socket:
-
Connect to the server via SSH
-
Review the SELinux audit log for more issues
# ausearch -m avc -ts recent
-
Generate new policy from the audit log
# ausearch -m avc -c php-fpm | audit2allow -M php-fpm
-
Activate the policy
# semodule -i php-fpm.pp
-
Verify
# semodule -l | grep php-fpm
Comments
0 comments
Please sign in to leave a comment.