<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>MemberManual/WebApplications/Nextcloud</title><revhistory><revision><revnumber>43</revnumber><date>2019-01-27 11:26:28</date><authorinitials>BjörnLindström</authorinitials><revremark>Changed cronjob to run every 15 minutes, that's what the admin page suggests (though the Nextcloud manual example has 5 minutes)</revremark></revision><revision><revnumber>42</revnumber><date>2019-01-26 09:57:52</date><authorinitials>BjörnLindström</authorinitials><revremark>Minimal upgrade instructions</revremark></revision><revision><revnumber>41</revnumber><date>2019-01-26 09:34:29</date><authorinitials>BjörnLindström</authorinitials></revision><revision><revnumber>40</revnumber><date>2019-01-08 03:55:18</date><authorinitials>BjörnLindström</authorinitials><revremark>Moving some work-in-progress stuff to talk page</revremark></revision><revision><revnumber>39</revnumber><date>2019-01-08 03:54:40</date><authorinitials>BjörnLindström</authorinitials><revremark>Keep recommendation to use sendmail directly, seems to be easiest overall</revremark></revision><revision><revnumber>38</revnumber><date>2019-01-08 03:48:41</date><authorinitials>BjörnLindström</authorinitials><revremark>Link to Talk page</revremark></revision><revision><revnumber>37</revnumber><date>2019-01-08 03:44:47</date><authorinitials>BjörnLindström</authorinitials><revremark>Moving stuff about making prettier urls to /Talk</revremark></revision><revision><revnumber>36</revnumber><date>2019-01-08 03:11:00</date><authorinitials>BjörnLindström</authorinitials></revision><revision><revnumber>35</revnumber><date>2019-01-08 03:08:11</date><authorinitials>BjörnLindström</authorinitials><revremark>Added Nextcloud .htaccess for reference</revremark></revision><revision><revnumber>34</revnumber><date>2019-01-08 02:57:46</date><authorinitials>BjörnLindström</authorinitials></revision><revision><revnumber>33</revnumber><date>2019-01-08 02:57:01</date><authorinitials>BjörnLindström</authorinitials><revremark>Updated a bit about the settings for neater URLs</revremark></revision><revision><revnumber>32</revnumber><date>2019-01-08 02:34:36</date><authorinitials>BjörnLindström</authorinitials><revremark>Restored instructions about utf8mb4 since that should work now</revremark></revision><revision><revnumber>31</revnumber><date>2019-01-06 10:26:44</date><authorinitials>BjörnLindström</authorinitials><revremark>Note about running maintenance repair after installation</revremark></revision><revision><revnumber>30</revnumber><date>2019-01-06 09:46:00</date><authorinitials>BjörnLindström</authorinitials><revremark>Removed thing about utf8mb4, not working on our MySQL setup</revremark></revision><revision><revnumber>29</revnumber><date>2019-01-06 07:51:40</date><authorinitials>BjörnLindström</authorinitials><revremark>Updated domtool section</revremark></revision><revision><revnumber>28</revnumber><date>2019-01-03 12:37:57</date><authorinitials>BjörnLindström</authorinitials><revremark>Neater URLs.</revremark></revision><revision><revnumber>27</revnumber><date>2019-01-03 11:12:31</date><authorinitials>BjörnLindström</authorinitials></revision><revision><revnumber>26</revnumber><date>2019-01-03 11:12:00</date><authorinitials>BjörnLindström</authorinitials></revision><revision><revnumber>25</revnumber><date>2019-01-03 11:11:38</date><authorinitials>BjörnLindström</authorinitials></revision><revision><revnumber>24</revnumber><date>2019-01-03 11:10:35</date><authorinitials>BjörnLindström</authorinitials><revremark>Disposition</revremark></revision><revision><revnumber>23</revnumber><date>2019-01-03 11:09:46</date><authorinitials>BjörnLindström</authorinitials><revremark>Disposition</revremark></revision><revision><revnumber>22</revnumber><date>2019-01-03 11:03:40</date><authorinitials>BjörnLindström</authorinitials></revision><revision><revnumber>21</revnumber><date>2019-01-03 11:00:24</date><authorinitials>BjörnLindström</authorinitials></revision><revision><revnumber>20</revnumber><date>2019-01-03 10:59:50</date><authorinitials>BjörnLindström</authorinitials><revremark>Some restructuring, and added stuff on MySQL charset</revremark></revision><revision><revnumber>19</revnumber><date>2019-01-03 10:14:28</date><authorinitials>BjörnLindström</authorinitials><revremark>Mail</revremark></revision><revision><revnumber>18</revnumber><date>2019-01-03 10:12:24</date><authorinitials>BjörnLindström</authorinitials><revremark>Some structure</revremark></revision><revision><revnumber>17</revnumber><date>2019-01-03 10:08:58</date><authorinitials>BjörnLindström</authorinitials></revision><revision><revnumber>16</revnumber><date>2019-01-03 10:07:54</date><authorinitials>BjörnLindström</authorinitials></revision><revision><revnumber>15</revnumber><date>2019-01-03 10:07:05</date><authorinitials>BjörnLindström</authorinitials><revremark>cron</revremark></revision><revision><revnumber>14</revnumber><date>2019-01-03 03:56:57</date><authorinitials>BjörnLindström</authorinitials><revremark>Note on dropping MySQL tables, instructions on converting some column types</revremark></revision><revision><revnumber>13</revnumber><date>2019-01-03 03:47:18</date><authorinitials>BjörnLindström</authorinitials></revision><revision><revnumber>12</revnumber><date>2019-01-03 03:46:55</date><authorinitials>BjörnLindström</authorinitials></revision><revision><revnumber>11</revnumber><date>2019-01-03 03:46:25</date><authorinitials>BjörnLindström</authorinitials></revision><revision><revnumber>10</revnumber><date>2019-01-03 03:46:00</date><authorinitials>BjörnLindström</authorinitials></revision><revision><revnumber>9</revnumber><date>2019-01-03 03:45:52</date><authorinitials>BjörnLindström</authorinitials><revremark>Data dir creation</revremark></revision><revision><revnumber>8</revnumber><date>2019-01-03 03:24:45</date><authorinitials>BjörnLindström</authorinitials><revremark>Skip the k5start, will get warnings anyway</revremark></revision><revision><revnumber>7</revnumber><date>2019-01-03 03:24:02</date><authorinitials>BjörnLindström</authorinitials><revremark>Cache config</revremark></revision><revision><revnumber>6</revnumber><date>2019-01-03 02:49:53</date><authorinitials>BjörnLindström</authorinitials><revremark>Changed unpacking command to result in daemon user ownership</revremark></revision><revision><revnumber>5</revnumber><date>2019-01-02 02:23:47</date><authorinitials>BjörnLindström</authorinitials><revremark>Note on creating database</revremark></revision><revision><revnumber>4</revnumber><date>2019-01-01 14:38:25</date><authorinitials>BjörnLindström</authorinitials></revision><revision><revnumber>3</revnumber><date>2019-01-01 14:35:11</date><authorinitials>BjörnLindström</authorinitials><revremark>Domtool sample</revremark></revision><revision><revnumber>2</revnumber><date>2019-01-01 14:26:22</date><authorinitials>BjörnLindström</authorinitials><revremark>Additional information</revremark></revision><revision><revnumber>1</revnumber><date>2019-01-01 14:08:56</date><authorinitials>BjörnLindström</authorinitials><revremark>Started page</revremark></revision></revhistory></articleinfo><para>Guide for installation of <ulink url="https://nextcloud.com">Nextcloud</ulink>. See <ulink url="https://wiki.hcoop.net/MemberManual/WebApplications/Nextcloud/MemberManual/WebApplications/Nextcloud/Talk#">/Talk</ulink> for discussion on improvements. </para><section><title>Create database</title><para>Postgresql should work, but Nextcloud recommends MySQL. See <ulink url="https://wiki.hcoop.net/MemberManual/WebApplications/Nextcloud/MemberManual/Databases#Create_a_Database">MemberManual/Databases#Create_a_Database</ulink>. We'll assume you name the database <code>${USER}_cloud</code>. </para></section><section><title>Software installation</title><section><title>Unpack</title><para>Get the Nextcloud tarball from <ulink url="https://nextcloud.com/install/#instructions-server">Nextcloud</ulink>. </para><para>Pick a directory where you'll host Nextcloud, for example <code>$HOME/www/next.your.domain</code>. We'll call it <code>$NEXTDIR</code>. </para><para>Also pick a directory for data, for example <code>$HOME/var/nextcloud</code>. We'll call it <code>$NEXTDATA</code>. </para><para>Unpack the source. </para><screen><![CDATA[unzip nextcloud-15.0.0.zip]]></screen><para>Move the resulting <code>nextcloud</code> directory to where you decided to have the document root. </para><screen><![CDATA[mv nextcloud $NEXTDIR]]></screen><para>Create an empty data directory in the document root. This is necessary for the duration of the installation, we'll delete it later. </para><screen><![CDATA[cd $NEXTDIR
mkdir data]]></screen></section><section><title>Permissions</title><para>Adjust directory permissions: </para><screen><![CDATA[fsr sa . system:anyuser none
fsr sa . $USER.daemon rlk
fsr sa config $USER.daemon rlidwk
fsr sa data $USER.daemon rlidwk
fsr sa apps $USER.daemon rlidwk]]></screen></section><section><title>Patch</title><para>Delete some lines in the file <code>core/Migrations/Version14000Date20180129121024.php</code>. This doesn't play well with the HCoop default of not granting DROP on tables. The easiest fix seems to be to manually drop these later. </para><screen><![CDATA[@@ -49,11 +49,6 @@
                /** @var ISchemaWrapper $schema */
                $schema = $schemaClosure();
]]><![CDATA[
-               $schema->dropTable('admin_sections');
-               $schema->dropTable('admin_settings');
-               $schema->dropTable('personal_sections');
-               $schema->dropTable('personal_settings');
-
                return $schema;
        }
 }]]></screen></section><section><title>Create real data directory</title><para>Create the data directory and give it correct permissions: </para><screen><![CDATA[mkdir $NEXTDATA
cd $NEXTDATA
fsr sa . system:anyuser none
fsr sa . $USER.daemon rlidwk]]></screen></section></section><section><title>Nextcloud installation wizard</title><para>Open up the web site, which should now show you the installation wizard. Fill it out like so: </para><screen><![CDATA[Data folder: $NEXTDATA
Database: MySQL/MariaDB
Username: whatever you like
Password: likewise
DB hostname: mysql]]></screen></section><section><title>Post-installation configuration</title><section><title>Update some column types</title><para>Run this command to convert a couple of column types that are not handled by the installer: </para><screen><![CDATA[cd $NEXTDIR
php7.2 occ db:convert-filecache-bigint]]></screen></section><section><title>Set DB charset</title><para>In the MySQL CLI, run: </para><screen><![CDATA[ALTER DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;]]></screen><para>Run these Nextcloud CLI commands: </para><screen><![CDATA[php7.2 occ config:system:set mysql.utf8mb4 --type boolean --value="true"
php7.2 occ maintenance:repair
php7.2 occ maintenance:mode --off]]></screen></section><section><title>Cache</title><para>Add this line to <code>$NEXDIR/config/config.php</code>, to enable the APCu cache: </para><screen><![CDATA['memcache.local' => '\OC\Memcache\APCu',]]></screen></section><section><title>Cron</title><para>Add a <ulink url="https://wiki.hcoop.net/MemberManual/WebApplications/Nextcloud/MemberManual/UsingCron#">cron job</ulink> like this replacing the variables with your username/path: </para><screen><![CDATA[*/15 * * * * k5start -qtUf /etc/keytabs/user.daemon/$USER -- /usr/bin/php7.2 -f $NEXTDIR/cron.php]]></screen></section></section><section><title>Domtool</title><para>Example Domtool config: </para><screen><![CDATA[web "cloud" where
    PhpVersion = php72;
    DocumentRoot = home "$NEXTDIR";
    SSL = use_cert "/etc/apache2/ssl/user/your.cert.pem";
with
    location "/" with
        unset_options [indexes, multiViews];
        directoryIndex ["index.php", "index.html"];
    end;
]]><![CDATA[
    expiresByType "text/css" access 1 weeks;
    expiresByType "application/javascript" access 1 weeks;
    expiresByType "image/svg" access 1 weeks;
    expiresByType "image/gif" access 1 weeks;
    expiresByType "application/font-woff2" access 1 weeks;
]]><![CDATA[
    setEnvIfNoCase "^Authorization$" "(.+)" ["XAUTHORIZATION=$1"];
]]><![CDATA[
    rewriteCond "%{HTTP_USER_AGENT}" "DavClnt" [];
    rewriteRule "^$" "/remote.php/webdav/" [redirectWith temp, last];
]]><![CDATA[
    rewriteRule ".*" "-" [env "HTTP_AUTHORIZATION" "%{HTTP:Authorization}"];
    rewriteRule "^\.well-known/host-meta" "/public.php?service=host-meta" [qsappend, last];
    rewriteRule "^\.well-known/host-meta\.json" "/public.php?service=host-meta-json" [qsappend, last];
    rewriteRule "^\.well-known/webfinger" "/public.php?service=webfinger" [qsappend, last];
    rewriteRule "^\.well-known/carddav" "/remote.php/dav/" [redirectWith permanent, last];
    rewriteRule "^\.well-known/caldav" "/remote.php/dav/" [redirectWith permanent, last];
    rewriteRule "^remote/(.*)" "remote.php" [qsappend, last];
    rewriteRule "^(?:build|tests|config|lib|3rdparty|templates)/.*" "-" [redirectWith notfound, last];
    rewriteCond "%{REQUEST_URI}" "!^/\.well-known/(acme-challenge|pki-validation)/.*" [];
    rewriteRule "^(?:\.|autotest|occ|issue|indie|db_|console).*" "-" [redirectWith notfound, last];
end;]]></screen><para>And to enforce SSL: </para><screen><![CDATA[web "cloud" with
    rewriteRule "^(.*)$" "https://next.your.domain$1" [redirectWith permanent];
end;]]></screen></section><section><title>Login</title><para>You should now be able to log in and look around Nextcloud. You may want to have a look at <code>Settings → Overview</code> for any warnings. You will see a bunch of warnings like this: </para><screen><![CDATA[Some app directories are owned by a different user than the web server one. This may be the case if apps have been installed manually. Check the permissions of the following app directories:
]]><![CDATA[
    /afs/hcoop.net/user/…]]></screen><para>These can be ignored. </para></section><section><title>Configuration in Nextcloud UI</title><section><title>cron</title><para>Go to <emphasis>Settings → Basic Settings</emphasis> and select the option <emphasis>Cron</emphasis> under <emphasis>Background jobs</emphasis> (since we set that up earlier). </para><para>You can check this page to ensure your cronjob is working. </para></section><section><title>Mail notifications</title><para>In <emphasis>Settings → Basic Settings</emphasis>, set: </para><screen><![CDATA[Send mode: Sendmail
Sendmail mode: pipe (-t)
From address: whatever@your.domain]]></screen></section></section><section><title>Cleanup</title><section><title>Delete default data directory</title><para>Since we use a new data directory we can delete the one in the document root: </para><screen><![CDATA[cd $NEXTDIR
rm -r data]]></screen></section></section><section><title>Upgrade</title><para>The one-click upgrade feature does not work well with our ACL setup, so it's probably easiest to use the manual method. Follow the <ulink url="https://docs.nextcloud.com/server/15/admin_manual/maintenance/manual_upgrade.html">steps here</ulink>, with these changes: </para><itemizedlist><listitem><para>Instead of 3 (Stop web server), disable the vhost/location in your Domtool configuration. </para></listitem><listitem><para>Instead of 10 (update ownership/permissions), update the file permissions in the new location like <link linkend="Permissions">during installation</link> </para></listitem></itemizedlist></section></article>