2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Nextcloud内でofficeファイルを編集できるようにしよう

Last updated at Posted at 2022-06-01

環境構築

前提条件

Nextcloudでonlyofficeを使用できるようにするには、制約としてそれぞれが別のサーバーに存在している必要があります。

ここではonlyoffice側のサーバーとしてGCP無料枠でe2-microインスタンスを利用します。

仮想マシン環境

【マシンスペック】
CPU: 2コア
メモリ: 1GB
HDD: 30GB

【OS】

$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

スワップ領域追加

このままだとおそらくメモリが足りないので、スワップ領域を追加しておきます。

# dd if=/dev/zero of=/swap bs=1M count=2048
# chmod 600 /swap && mkswap /swap && swapon /swap

OS再起動時の自動マウント設定
# echo -e "/swap          swap       swap    defaults        0 0" >> /etc/fstab
# cat /etc/fstab

SELinux無効化 & タイムゾーン変更

例のごとくSELinuxくんが未認証のアクセスを遮断してくるので無効化します。
またサーバー側タイムゾーンがアメリカになっていると何故か動作しなかったのでこちらも変更します。

# vim /etc/selinux/config

SELINUX=enforcing
       ↓
SELINUX=disabled

# timedatectl set-timezone Asia/Tokyo
# reboot now

Node.jsインストール

Node.jsをインストールします。

# curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash -
# yum install nodejs

Nginxのインストール&初期設定

Nginxをインストールします。

# yum install epel-release
# yum install nginx
# vim /etc/nginx/nginx.conf

serverディレクティブ内の一部を変更します。
    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

↓
    server {
        listen       80;
        listen       [::]:80;
        server_name  _;
        root         /usr/share/nginx/html;

PostgreSQLのインストール&初期設定

# yum install postgresql postgresql-server
# postgresql-setup initdb

# vim /var/lib/pgsql/data/pg_hba.conf
権限設定を変更します

ident→trustへ変更

host    all             all             127.0.0.1/32            trust
host    all             all             ::1/128                 trust

# systemctl start postgresql && systemctl enable postgresql
# cd /tmp
# sudo -u postgres psql -c "CREATE DATABASE onlyoffice;"
# sudo -u postgres psql -c "CREATE USER onlyoffice WITH password 'パスワードを入力';"
# sudo -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;"

Redis・RabbitMQのインストール

# yum install redis rabbitmq-server
# systemctl enable redis rabbitmq-server
# systemctl start redis rabbitmq-server

OnlyOfficeのインストール

比較的大きなパッケージなので、microインスタンスだとインストールにかなりの時間が掛かるので気長に待ちましょう。

# yum install https://download.onlyoffice.com/repo/centos/main/noarch/onlyoffice-repo.noarch.rpm
# yum install onlyoffice-documentserver-de
# systemctl start supervisord nginx
# systemctl enable supervisord nginx

SSL認証

ドメインを取得して、SSL証明書を取得します。
取得した証明書を適当なフォルダに配置してください。

ここではcertbotを使用してLet's Encryptで取得します。

# yum install certbot
# certbot certonly
※standaloneモードで失敗する場合は、nginxを一度終了させてからもう一度トライしてください

NginxでのSSL接続を有効化

設定ファイルを削除
# rm /etc/nginx/conf.d/*.conf
# cp -p /etc/onlyoffice/documentserver/nginx/ds-ssl.conf.tmpl /etc/nginx/conf.d/onlyoffice-documentserver.conf
# vim /etc/nginx/conf.d/onlyoffice-documentserver.conf

ssl_certificateとssl_certificate_keyを先程配置した証明書ファイルに設定

certbotを使用して取得した場合
ssl_certificate /etc/letsencrypt/live/[ONLYOFFICEサーバのFQDN]/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/[ONLYOFFICEサーバのFQDN]/privkey.pem;

# systemctl restart nginx

ONLYOFFICE Document Serverの初期設定

# bash /usr/bin/documentserver-configure.sh
Configuring PostgreSQL access...
Host: localhost
Database name: onlyoffice
User: onlyoffice
Password: onlyoffice 設定したパスワードを入力
Trying to establish PostgreSQL connection... OK
Installing PostgreSQL database... OK

Configuring redis access...
Host: localhost
 
Trying to establish redis connection... OK
Configuring RabbitMQ access...
Host: localhost:5672
User: guest
Password: パスワードを入力
Trying to establish RabbitMQ connection... OK
Restarting services... OK

nextcloudとDocument Serverの設定

デフォルトで認証されていないアクセスを弾く設定になっているので変更します。

まずNextcloudに追記

# vim /var/www/html/nextcloud/config/config.php

末尾に追記
  array (
    'verify_peer_off' => TRUE,
  ),

続いてDocument Server

# vim /etc/onlyoffice/documentserver/default.json

135行あたりの"rejectUnauthorized": true
を
"rejectUnauthorized": false
へ変更

Nextcloudへ設定

NextcloudのアプリストアからOnlyofficeをインストールし、設定画面を開く

ONLYOFFICE Docsアドレスへ "https://FQDN名" を入力し、証明書の検証を無効化してセットアップ完了

image.png

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?