NextCloud 13 から 14 系にアップデートする

Linux
この記事は約8分で読めます。
この記事は最終更新日より 1 年以上経過しています。
画像やリンクが無効になっている可能性もあるのでご了承下さい。

 自サバに導入しているクラウド環境を構築してくれる NextCloud へアクセスしたらバージョン 14.0 がリリースされたとの通知が出た。
 Web 上での自動アップデートではなくて手動でやる必要がある雰囲気だったので早速アップデートを行ってみた。

動作環境

  • OS : CentOS Linux release 7.5.1804
  • Web Server : Nginx 1.15.3, php-fpm 7.2.9
  • DB : MariaDB 10.1.36

更新作業

 作業自体は自サバなので割と緩慢な root 作業としたが、shell もちユーザーがファイルを所有しているならそちらに su した方が良いだろう。
 NextCloud を設置しているパスをここでは /path/to/documentroot/nextcloud とし、ファイルの所有は nginx ユーザーとする。
 DB バックアップ時の mysqldump では NextCloud の DB にアクセス出来る root 等のユーザーで行う。

# DB バックアップ
mysqldump -u USERNAME -p NEXTCLOUD_DB > ~/nextcloud13.sql
cd /path/to/documentroot/nextcloud
# 念のためメンテナンスモードにした
sudo -u nginx php occ maintenance:mode --on
cd ..
# NextCloud 14.0.0 のダウンロード
curl -L -O https://download.nextcloud.com/server/releases/nextcloud-14.0.0.zip
# 既存の NextCloud をリネームする事でバックアップとする
mv ./nextcloud ./nextcloud13
# NextCloud 14 のアーカイブを展開
unzip nextcloud-14.0.0.zip
# 設定ファイルを NextCloud 13 の物を NextCloud 14 でそのまま使う
cp ./nextcloud13/config/config.php ./nextcloud/config/config.php
chown -R nginx:nginx ./nextcloud

 ここまでで取り敢えず NextCloud 14 へのアップグレード完了一歩手前になる。
 次に NextCloud のアーカイブに含まれる occ コマンドを用いてアップグレード作業を行う。

cd /path/to/documentroot/nextcloud
sudo -u nginx php occ db:add-missing-indice
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Check indices of the share table.
Adding additional share_with index to the share table, this can take some time...
Share table updated successfully.
Adding additional parent index to the share table, this can take some time...
Share table updated successfully.
Adding additional mtime index to the filecache table, this can take some time...
Filecache table updated successfully.

sudo -u nginx php occ db:convert-filecache-bigint
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
This can take up to hours, depending on the number of files in your instance!
Continue with the conversion (y/n)? [n] y

sudo -u nginx php occ upgrade
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Set log level to debug
Turned on maintenance mode
Updating database schema
Updated database
Disabled incompatible app: bookmarks
Disabled incompatible app: bruteforcesettings
Disabled incompatible app: calendar
Disabled incompatible app: contacts
Disabled incompatible app: notes
Disabled incompatible app: tasks
Disabled incompatible app: templateeditor
(中略
Update successful
Turned off maintenance mode
Reset log level

 これで NextCloud 14.0.0 が動作するようになるのでブラウザからアクセスしてチェックする。
 「Disabled incompatible app:」に示されるアプリは互換性の問題で無効化されているので別途対応する必要がある。
 例えば次の様にブラウザ上からアクセスして Calendar などの常用アプリを改めて追加出来るなら行う。

 しかし筆者の場合、ダウンロード元の github から 502 や 503 エラーが帰ってきてしまったので、Windows 上でブラウザから github にアクセスし、個々のアプリをダウンロード。sftp なりでサーバー側へアーカイブを転送した後に手動でアプリの設置をしたあとに NextCloud からアプリの有効化を行った。
 もし同様にしてアプリを個別にダウンロードする場合、次のページに各種リポジトリがあるのでダウンロードが可能。

Nextcloud
📱☁️💻 A safe home for all your data – community-driven, free & open source 👏 - Nextcloud

追加設定

 上記更新作業で occ コマンドを叩くと「The current PHP memory limit is below the recommended value of 512MB.」なんて口うるさくメッセージが出るので /etc/php.ini の memory_limit をみたらデフォルトの 128MB 設定になっていた為、次の様に設定を変更。

; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 512M

 コマンドを叩くと言われるなら php-fpm 側も設定しておこうと言うことで NextCloud で使っている pool に次の一行を追加した。

php_admin_value[memory_limit] = 512M

アップグレード完了後の確認

 NextCloud にアクセスして設定にある概要から一番上にあるチェックに全て合格となることを確認する。

 実は初回アクセス時には新たに注意書きが表示されていた。サーバー側で出力する HTTP ヘッダーに Referrer に関する設定が足りないという事だったので、Nginx 側の設定に次の 1 行を追記した。
 no-referrer-when-downgrade同一オリジン、同一スキーマなら referrer を送信するが https から http への downgrade 時には送信しないという動作を採用してみた。

add_header Referrer-Policy "no-referrer-when-downgrade";

 ついでに NextCloud が用意しているセキュリティスキャンも行ってみると良いかも知れない。

Nextcloud Security Scanner
Nextcloud is an open source, self-hosted file share and communication platform. Access& sync your fi...

 筆者の設定した NextCloud は Rating A+ だったので何ら問題はないハズ。

さいごに

 NextCloud 14 になったことで何が出来るのかは更新履歴を読むといい。

Nextcloud 14 now available with Video Verification, Signal/Telegram 2FA support, Improved Collaboration and GDPR compliance - Nextcloud
Nextcloud 14 comes with many improvements you will feel in your day to day workflow! That includes s...

 因みに筆者は一人で使ってるので新機能を活用する予定も無く、ただ最新版を入れてみたかったという事で今回の作業を行った。
 どうせ何れは移行するだろうし早めの作業としておけば後は安穏と出来るからまぁいいかなと。

著者プロフィール
ぶっち

本格的に PC へ触れ始めてたのは 1990 年位から。
興味は PC 全般。OS は Windows と Linux などを嗜む。
プログラマやネットワークエンジニアを経てフリーに活動している 2 児の父な 40 代半ばのおじさんです。

ぶっちをフォローする

コメント

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.