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:
<strong>#</strong> <span style="color: #0000ff;">su postgres -c psql</span> psql (9.1.9) Type "help" for help. <strong>postgres=#</strong>
(If you do not have peer authentication enabled for all users, you need to enter a password.)
Create the user www-data, [1]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).
<strong>postgres=#</strong> <span style="color: #0000ff;">create role "www-data";</span> CREATE ROLE
Create the new database, granting ownership (and thus all rights) to www-data:
<strong>postgres=#</strong> <span style="color: #0000ff;">create database "owncloud" owner "www-data";</span> 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/
Image credit: The key logo on this page was adapted from Wikimedia user MesserWoland‘s Crypto Key, which is licensed under CC BY-SA 3.0, among others.