APS installer in chrooted PHP-FPM: database connection problems
Use case:
- I have a server running web and db
- The server is running a site called example.com, using chrooted php-fpm
- I use the APS installer to install WordPress to example.com
Problem: the installed wp-config.php
contains the database host localhost:3306
, which causes PHP to attempt a connection to a unix socket rather than over TCP/IP. The unix socket file does not exist in the chroot, so the database connection fails.
Possible solutions:
- from what I read it is not possible to create a link to a socket file, so jailkit is not an option
- using bind mounts could be an option, but there are already thousands of bind mounts on this server for all the log files, so I don't want to create even more
- in https://git.ispconfig.org/ispconfig/ispconfig3/blob/master/interface/lib/classes/aps_guicontroller.inc.php#L249 , we could do something like:
$settings['main_database_host'] = 'localhost';
$mysql_db_remote_access = 'n';
$mysql_db_remote_ips = '';
if (some condition) {
$settings['main_database_host'] = '127.0.0.1';
$mysql_db_remote_access = 'y';
$mysql_db_remote_ips = '127.0.0.1';
}
I think option 3 would be nicest, but it might break compatibility for people who run MySQL with skip-networking
php_fpm_chroot
is enabled (from !870 (diffs)).
Just wondering if you guys agree, or if you perhaps see other/better options?