panel.ini setting to select 127.0.0.1 or localhost for WPT WordPress installations
When using CloudLinux's alt-php versions and when using Plesk's php version management facility instead of CloudLinux PHP Selector, the default path to mysql.sock is not set, or in some cases incorrectly set to /tmp/mysql.sock.
Any php script, including WordPress, that is set to use "localhost" to connect to the database will then fail to connect. This can cause severe problems with the WordPress Toolkit.
If, instead of localhost, the host address is set to 127.0.0.1, php uses a network connection instead of trying to connect to mysql.sock, and all is well. Naturally this assumes that mysql/mariadb listens on 127.0.0.1 but that is usually the case for CloudLinux/RHEL-downstream distributions as far as I'm aware.
The alternative is to tell php where mysql.sock is located by adding mysql.defaultsocket = /var/lib/mysql/mysql.sock, mysqli.defaultsocket = /var/lib/mysql/mysql.sock and pdomysql.defaultsocket = /var/lib/mysql.sock either on a per-domain basis or in the main php.ini fo9r all domains (per version of php).
I suggest adding a panel.ini setting for wpt that would allow the administrator to set their preference of localhost or 127.0.0.1 for WordPress installations.
As an extension to this, I also suggest that in panel.ini under [php] it could be made possible to specify the default path to mysql.sock for the various libraries, just as it is currently possible to specify disable_functions settings.
Thank you for your idea! We will consider this functionality in upcoming releases if it will be popular.
Everyone, please continue voting for this feature if you consider it important.
Faris Raouf commented
(I'm afraid Uservoice has removed the underscores between "default" and "socket" in the php directives pointing to mysql.sock I typed in)