roundcube / roundcubemail

The Roundcube Webmail suite
https://roundcube.net
GNU General Public License v3.0
5.79k stars 1.62k forks source link

Question: Connect to (PostgreSQL) database via unix socket #7579

Closed thomas-mc-work closed 4 years ago

thomas-mc-work commented 4 years ago

I'd like to connect to my PostgreSQL database via a Unix socket file. I can see that this is somehow supported by the database wrapper class and also by the underlying library (PDO):

https://github.com/roundcube/roundcubemail/blob/a5c2b4360c/program/lib/Roundcube/rcube_db.php#L1255

But I can't figure out how to assemble the required DSN string. It's probably an easy task for someone who is known with that source code.

alecpl commented 4 years ago

Try unix(/path/to/socket) in place of the hostname.

thomas-mc-work commented 4 years ago

Sorry for the late reply, @alecpl . I was successful with your hint. Thank you very much, Aleksander!

JFTR for other users, my db_dsnw value for other users:

pgsql://username:password@unix(/run/postgresql)/my_database

Note that you have to omit the actual name of the socket file (.s.PGSQL.5432)!

It would be great to have this in the documentation. This is a low hanging no-brainer for all setups that are living on the same machine. You get more performance without any downsides. In a large scale this would even help to reduce the power consumption of the server and thus help the environment. :deciduous_tree: :seedling: