PostgreSQL on macOS Server?
Is PostgreSQL installed by default on macOS Server, or ought I install it? If I ought install it, will it conflict with macOS Server services?
Mac mini (Late 2012), macOS Sierra (10.12.2)
Is PostgreSQL installed by default on macOS Server, or ought I install it? If I ought install it, will it conflict with macOS Server services?
Mac mini (Late 2012), macOS Sierra (10.12.2)
You can use Server's Postgres installation if it has everything you need. (It's a somewhat striped-down install, as many of the extensions have been removed.) The services in Server.app that use Postgres use a unix file socket rather than an TCP socket, so you can start your own instance of the Postgres server to listen on port 5432. Just don't modify anything in /Applications/Server.app or /Library/Server.
However, given that Apple could decide to pull or modify the bundled Postgres in the future, I would recommend that you install your own Postgres in the "default" locations. This lets you own that copy, so you won't be impacted by any changes that Apple might make in the future. (PHP, for instance, has been moved around in Server over the years.) Also, Apple is currently still using Postgres 9.4, while version 9.6 has been out for a while, and there are some nice additions in Postgres 9.5 and 9.6 which you might want. If you use your own version, you can change it however you need w/o fear of breaking Server.
Your default installation of Postgres should not impact the server unless you try to put your cluster files or socket in /Library/Server, so don't do that. (That directory is only for Server.app, and anything you put in there could get overwritten if you choose the wrong names.)
Postgres is a very well behaved tool, and doesn't make any assumptions about where any of its executable or config files are, which makes it a very low-risk thing to add to a system that is already using Server. It's also an awesome database, so congratulations on picking Postgres (MAPP) instead of the more common choice (MAMP). 😉
Thanks for the answer John. Hopefully, you don't mind a few follow up questions (note that I'm very much an amateur when it comes to IT, but also quite curious).
The context for my question is that I am looking to set up my macOS Server (which is currently running and offering a host of services) as a 'production environment' for hosting my web site(s) (mostly for experimental purposes, and most likely just on my local network). I have a Macbook Air on which I have a 'development environment' set up where I will 'develop' my sites (actually, I have really only set up an instance of PostgreSQL so far).
Typically, web development tutorials always get you to install third-party web stacks (e.g. MAMP). I find those stacks make learning the technology on which they are based very difficult, as you always end up having to learn the implementation of the third-party stack rather than the technology itself. So, I spent the last day or so learning how to install PostgreSQL from the source code onto my Macbook Air. I would like to do the same on my Server; however, I don't want to reinstall something already provided, and I don't want to interfere with the services I'm hosting on my server.
If, as you say, there is an instance of PostgreSQL server installed on macOS Server, it is not installed in the default location: /usr/local/pgsql, and it is not listening on the default port 5432 (at least not according to the port scan I did with Network Utility). I wonder whether once I find it (I actually just found the binaries with the 'which' command in terminal at '/Applications/Server.app/Contents/ServerRoot/usr/bin'), if it will allow me to create roles and database clusters for my own purposes separate from those of macOS Server.
To summarize:
Can you answer these questions? Is there an information source available to me where I can read up on accessing PostgreSQL as installed on macOS Server?
Thanks for all the help!
Pierre
Yes PostgreSQL is installed as standard on a Mac server. It is used for example by Profile Manager and the Wiki modules of Server.app.
Therefore it is best not to try installing a second copy, it is however possible but you need to configure your copy so it does not conflict.
If you do not have Server.app installed then you can install your own copy since the built-in one will not be active.
Thanks very much mscott_mdm, that was exceptionally helpful!
PostgreSQL on macOS Server?