I like PostgreSQL and ownCloud, but I do not like passwords, especially if they have to stored in plain text in a widely readable configuration file. So, I wanted to use PostgreSQL peer authentication with ownCloud as well.
As root, do the following:
# su postgres -c psql psql (9.1.9) Type "help" for help. postgres=#
(If you do not haveÂ peer authenticationÂ enabled for all users, you need to enter a password.)
Create the user www-data, If your Web server runs under a different user name, replace all occurrences of “www-data” in this document with that name. (note that it needs quoting, as it contains a hyphen).
postgres=# create role "www-data"; CREATE ROLE
Create the new database, granting ownership (and thus all rights) to www-data:
postgres=# create database "owncloud" owner "www-data"; CREATE DATABASE
As the database server is now ready, we install ownCloud and visit its start page in your favorite web browser (typically, along the lines of https://example.org/owncloud/ ).
- Fill in the desired admin account name and password.
- Expand the “Advanced” view and select PostgreSQL.
- Set the database user to www-data.
- Leave the database password empty (there is none, and it will not be needed).
- Set the database name to owncloud.
- Set the host name to /var/run/postgresql .
Peer authentication would work automagically, if the host name could be left empty: PostgreSQL clients would connect using the local Unix domain socket. Unfortunately, ownCloud insist on a non-empty host name. However, a path to the Unix domain socket (or, as in this case, it’s container directory) causes PostgreSQL to use the Unix domain socket. On Ubuntu, this is /var/run/postgresql; on other Linux distributions, this may vary, look for “unix_socket_directory” in /etc/postgresql/<version>/main/postgresql.confÂ .