Index: server/databases/postgresql.xml
===================================================================
--- server/databases/postgresql.xml	(revision 8b28cb4abb140a544647ac58c8800fdb80590500)
+++ server/databases/postgresql.xml	(revision 8753831ea3fc9b1eeef5a988b1d8cf62586c2091)
@@ -88,4 +88,14 @@
     <title>Installation of PostgreSQL</title>
 
+    <para>
+      For enhanced security, it is better to have a dedicated group and user
+      for running the PostgreSQL server. First, issue as the
+      <systemitem class="username">root</systemitem> user:
+    </para>
+
+<screen role="root"><userinput>groupadd -g 41 postgres &amp;&amp;
+useradd -c "PostgreSQL Server" -g postgres -d /srv/pgsql/data \
+        -u 41 postgres</userinput></screen>
+
     <para>Install <application>PostgreSQL</application> with the
     following commands: </para>
@@ -109,7 +119,7 @@
     you need to stop all PostgreSQL servers if any are running. If a previous
     version of PostgreSQL is installed, it may be necessary to use
-    <emphasis>--disable-rpath</emphasis> with <emphasis>configure</emphasis> to
-    avoid failures, but <command>installing the binaries created using this
-    switch is not recommended</command>. To test the results, issue:
+    <command>--disable-rpath</command> with <command>configure</command> to
+    avoid failures, but <emphasis>installing the binaries created using this
+    switch is not recommended</emphasis>. To test the results, issue:
     <command>make check</command>.</para>
 
@@ -143,9 +153,4 @@
 <screen role="root"><userinput>install -v -dm700 /srv/pgsql/data &amp;&amp;
 install -v -dm755 /run/postgresql &amp;&amp;
-
-groupadd -g 41 postgres &amp;&amp;
-useradd -c "PostgreSQL Server" -g postgres -d /srv/pgsql/data \
-        -u 41 postgres &amp;&amp;
-
 chown -Rv postgres:postgres /srv/pgsql /run/postgresql</userinput></screen>
 
@@ -155,12 +160,115 @@
 <screen role="root"><userinput>su - postgres -c '/usr/bin/initdb -D /srv/pgsql/data'</userinput></screen>
 
-    <para>Again as the <systemitem class="username">root</systemitem> user,
-    start the database server with the following command:</para>
+  </sect2>
+
+  <sect2 role="commands">
+    <title>Command Explanations</title>
+
+    <para>
+      <command>sed -i ...</command>: This sed changes server socket location
+      from <filename class="directory">/tmp</filename> to
+      <filename class="directory">/run/postgresql</filename><!-- and fix up the
+      regression tests to use <filename class="directory">/tmp</filename> so
+      that they can work reliably-->.
+    </para>
+
+    <para><parameter>--docdir=/usr/share/doc/postgresql-&postgresql-version;</parameter>:
+    This switch puts the documentation in a versioned directory.</para>
+
+    <para><parameter>--enable-thread-safety</parameter>: This switch makes the
+    client libraries thread-safe by allowing concurrent threads in
+    <filename class="libraryfile">libpq</filename> and ECPG programs to safely
+    control their private connection handles.</para>
+
+    <para><option>--with-openssl</option>: builds the package  with support for
+    <application>OpenSSL</application> encrypted connections.</para>
+
+    <para><option>--with-perl</option>: builds the PL/Perl server-side language.
+    </para>
+
+    <para><option>--with-python</option>: builds the PL/Python server-side
+    language. Add PYTHON=/usr/bin/python3 for Python3 support.</para>
+
+    <para><option>--with-tcl</option>: builds the PL/Tcl server-side language.</para>
+
+  </sect2>
+
+  <sect2 role="configuration">
+    <title>Configuring PostgreSQL</title>
+
+    <sect3 id="postgresql-config">
+      <title>Config Files</title>
+
+      <para><filename>$PGDATA/pg_ident.con</filename>,
+      <filename>$PGDATA/pg_hba.conf</filename> and
+      <filename>$PGDATA/postgresql.conf</filename></para>
+
+      <indexterm zone="postgresql postgresql-config">
+        <primary sortas="e-A.PGDATA-pg_ident.con">$PGDATA/pg_indent.con</primary>
+      </indexterm>
+
+      <indexterm zone="postgresql postgresql-config">
+        <primary sortas="e-A.PGDATA-pg_hba.conf">$PGDATA/pg_hba_conf</primary>
+      </indexterm>
+
+      <indexterm zone="postgresql postgresql-config">
+        <primary sortas="e-A.PGDATA-postgresql.conf">$PGDATA/postgresql.conf</primary>
+      </indexterm>
+
+      <para>The <envar>PGDATA</envar> environment variable is used to
+      distinguish database clusters from one another by setting it to
+      the value of the directory which contains the cluster desired.
+      The three configuration files exist in every <filename
+      class="directory">PGDATA/</filename> directory. Details on the
+      format of the files and the options that can be set in each can
+      be found in <ulink
+      url="file:///usr/share/doc/postgresql-&postgresql-version;/html/index.html"/>.</para>
+
+    </sect3>
+
+    <sect3  id="postgresql-init">
+      <title><phrase revision="sysv">Boot Script</phrase>
+             <phrase revision="systemd">Systemd Unit</phrase></title>
+
+      <para>Install the
+      <phrase revision="sysv"><filename>/etc/rc.d/init.d/postgresql</filename>
+      init script</phrase>
+      <phrase revision="systemd"><filename>postgresql.service</filename>
+      unit</phrase> included in the
+      <xref linkend="bootscripts" revision="sysv"/>
+      <xref linkend="systemd-units" revision="systemd"/> package.</para>
+
+      <indexterm zone="postgresql postgresql-init">
+        <primary sortas="f-postgresql">postgresql</primary>
+      </indexterm>
+
+<screen role="root"><userinput>make install-postgresql</userinput></screen>
+
+    </sect3>
+
+    <sect3>
+      <title>Starting the PostgreSQL Server and Creating a Sample Database</title>
+
+      <para>
+        The database server can be manually started with the following command
+        (as the <systemitem class="username">root</systemitem> user):
+      </para>
 
 <screen role="root"><userinput>su - postgres -c '/usr/bin/postgres -D /srv/pgsql/data > \
                   /srv/pgsql/data/logfile 2&gt;&amp;1 &amp;'</userinput></screen>
-
-    <para>Still as user <systemitem class="username">root</systemitem>, create
-    a database and verify the installation:</para>
+      <note>
+        <para>
+          If you are scripting this part, you should wait for the server to
+          start before going on, by adding for example
+          <command>sleep 2</command> after the above command.
+        </para>
+      </note>
+
+      <para>
+        The instructions below show how to create a database, add a table to
+        it, insert some rows into the table and select them, to verify that the
+        installation is working properly. Still as user <systemitem
+        class="username">root</systemitem>, issue:
+      </para>
 
 <screen role="root"><userinput>su - postgres -c '/usr/bin/createdb test' &amp;&amp;
@@ -175,102 +283,10 @@
 echo "select * from t1;" | (su - postgres -c '/usr/bin/psql test')</userinput></screen>
 
-    <para>To shut down the server, as <systemitem
-    class="username">root</systemitem>:</para>
+      <para>
+        When you are done with testing, you can shut down the server, by issuing
+        as <systemitem class="username">root</systemitem>:
+      </para>
 
 <screen role="root"><userinput>su - postgres -c "/usr/bin/pg_ctl stop -D /srv/pgsql/data"</userinput></screen>
-
-  </sect2>
-
-  <sect2 role="commands">
-    <title>Command Explanations</title>
-
-    <para>
-      <command>sed -i ...</command>: This sed changes server socket location
-      from <filename class="directory">/tmp</filename> to
-      <filename class="directory">/run/postgresql</filename><!-- and fix up the
-      regression tests to use <filename class="directory">/tmp</filename> so
-      that they can work reliably-->.
-    </para>
-
-    <para><parameter>--docdir=/usr/share/doc/postgresql-&postgresql-version;</parameter>:
-    This switch puts the documentation in a versioned directory.</para>
-
-    <para><parameter>--enable-thread-safety</parameter>: This switch makes the
-    client libraries thread-safe by allowing concurrent threads in
-    <filename class="libraryfile">libpq</filename> and ECPG programs to safely
-    control their private connection handles.</para>
-
-    <para><option>--with-openssl</option>: builds the package  with support for
-    <application>OpenSSL</application> encrypted connections.</para>
-
-    <para><option>--with-perl</option>: builds the PL/Perl server-side language.
-    </para>
-
-    <para><option>--with-python</option>: builds the PL/Python server-side
-    language. Add PYTHON=/usr/bin/python3 for Python3 support.</para>
-
-    <para><option>--with-tcl</option>: builds the PL/Tcl server-side language.</para>
-
-    <para><command>groupadd ...</command>; <command>useradd ...</command>:
-    These commands add an unprivileged user and group to run the database
-    server.</para>
-
-    <para><command>createdb test; create table t1; insert into t1 values...;
-    select * from t1</command>: Create a database, add a table to it, insert
-    some rows into the table and select them to verify that the installation
-    is working properly.</para>
-
-  </sect2>
-
-  <sect2 role="configuration">
-    <title>Configuring PostgreSQL</title>
-
-    <sect3 id="postgresql-config">
-      <title>Config Files</title>
-
-      <para><filename>$PGDATA/pg_ident.con</filename>,
-      <filename>$PGDATA/pg_hba.conf</filename> and
-      <filename>$PGDATA/postgresql.conf</filename></para>
-
-      <indexterm zone="postgresql postgresql-config">
-        <primary sortas="e-A.PGDATA-pg_ident.con">$PGDATA/pg_indent.con</primary>
-      </indexterm>
-
-      <indexterm zone="postgresql postgresql-config">
-        <primary sortas="e-A.PGDATA-pg_hba.conf">$PGDATA/pg_hba_conf</primary>
-      </indexterm>
-
-      <indexterm zone="postgresql postgresql-config">
-        <primary sortas="e-A.PGDATA-postgresql.conf">$PGDATA/postgresql.conf</primary>
-      </indexterm>
-
-      <para>The <envar>PGDATA</envar> environment variable is used to
-      distinguish database clusters from one another by setting it to
-      the value of the directory which contains the cluster desired.
-      The three configuration files exist in every <filename
-      class="directory">PGDATA/</filename> directory. Details on the
-      format of the files and the options that can be set in each can
-      be found in <ulink
-      url="file:///usr/share/doc/postgresql-&postgresql-version;/html/index.html"/>.</para>
-
-    </sect3>
-
-    <sect3  id="postgresql-init">
-      <title><phrase revision="sysv">Boot Script</phrase>
-             <phrase revision="systemd">Systemd Unit</phrase></title>
-
-      <para>Install the
-      <phrase revision="sysv"><filename>/etc/rc.d/init.d/postgresql</filename>
-      init script</phrase>
-      <phrase revision="systemd"><filename>postgresql.service</filename>
-      unit</phrase> included in the
-      <xref linkend="bootscripts" revision="sysv"/>
-      <xref linkend="systemd-units" revision="systemd"/> package.</para>
-
-      <indexterm zone="postgresql postgresql-init">
-        <primary sortas="f-postgresql">postgresql</primary>
-      </indexterm>
-
-<screen role="root"><userinput>make install-postgresql</userinput></screen>
 
     </sect3>
