blog.gogodiet.net Open in urlscan Pro
2001:e42:102:1817:160:16:231:189  Public Scan

URL: https://blog.gogodiet.net/itsupport/581/2022/08/30/
Submission: On March 08 via api from US — Scanned from JP

Form analysis 0 forms found in the DOM

Text Content

コンテンツへスキップ
FlatterMe
Dart, Flutter & others
メニュー
 * Dart
   * Dartとは
   * Dart 演算子 一覧
   * Dart 変数の宣言
   * Dart 変数とスコープ
   * Dart 基本の変数の型 一覧
 * 社内SE
   * 窓口対応
   * プログラム
   * OS
   * その他
 * 家族
   * DIY
   * 子供が弱視と診断された
     * 弱視診断までの経緯と診断後の親の気持ち
     * 弱視の眼鏡の選び方
     * 弱視について調べたこと
     * 弱視治療の経過記録
   * 都内に家を買った話
 * 投稿一覧

 * English
 * 日本語

メニューを閉じる
 * Dartサブメニューを表示
   * Dartとは
   * Dart 演算子 一覧
   * Dart 変数の宣言
   * Dart 変数とスコープ
   * Dart 基本の変数の型 一覧
 * 社内SEサブメニューを表示
   * 窓口対応
   * プログラム
   * OS
   * その他
 * 家族サブメニューを表示
   * DIY
   * 子供が弱視と診断されたサブメニューを表示
     * 弱視診断までの経緯と診断後の親の気持ち
     * 弱視の眼鏡の選び方
     * 弱視について調べたこと
     * 弱視治療の経過記録
   * 都内に家を買った話
 * 投稿一覧

 * English
 * 日本語

カテゴリー
その他 社内SE


NEXTCLOUD & COLLABORA ONLINEをOPENLITESPEEDで動かす

 * 投稿者 作成者: 管理人
 * 投稿日 2022年8月30日

PHPを高速で動作させるopenLiteSpeedでNextCloudとcollabora
onlineの設定を行った。NextCloudが重いと悩んでいる方は軽くなるので、お試しあれ。

(2022年9月現在の最新パッケージでの構築方法だが、古い環境でも構築方法はほぼ変わらないので参考になるかと思う。)

構築環境

 * OS Ubuntu 22.04
 * NextCloud 24.04
 * OpenLiteSpeed 1.7 + PHP 8.1
 * Collabora Online 22
 * SSL LetsEncrypt

要点

 * Collabora
   Onlineは設定のnum_prespawn_childrenを増やして軽快に。proxyはipv4のみとするので、net.protoをipv4のみに変更
 * NextCloudの.htaccessは、occ maintenance:update:htaccess
   で環境に合わせたものを生成しなおす。そのrewrite部分をOpenLiteSpeedのrewrite機能に設定する。(生成した.htaccessは使わない。)
 * Collabora OnlineはOpenLiteSpeedでReverse Proxy設定

前提

 * OSの環境構築はできている。
 * mariaDBを使用する。(インストールは終わっている)
 * 本稿の設定方法では、以下のサイトを作成する。
   NextCloud https://nc.you.com/
   Collabora Online https://lool.you.com/
   
   参考にする場合、自前のドメインに読み替えのこと。また、NextCloudをサブフォルダーに配置する場合などは適宜読み替えのこと。


初期設定

DB設定 使用するDB環境にNextCloud用のDBを作成しておく。

CREATE DATABASE nc;
CREATE USER 'nextcloud'@'127.0.0.1' IDENTIFIED BY 'yourPassWord';
GRANT ALL ON nc.* TO 'nc'@'127.0.0.1';

FLUSH PRIVILEGES;

SQL







xxxxxxxxxx



 

CREATE DATABASE nc;

CREATE USER 'nextcloud'@'127.0.0.1' IDENTIFIED BY 'yourPassWord';

GRANT ALL ON nc.* TO 'nc'@'127.0.0.1';

​

FLUSH PRIVILEGES;




rootユーザに変更(以下は基本rootで設定)

sudo su -

Shell







xxxxxxxxxx



 

sudo su -




hostsを変更

vi /etc/hosts
---
127.0.0.1 localhost nc.you.com lool.you.com
127.0.1.1 nc.you.com lool.you.com
---

Shell







xxxxxxxxxx



 

vi /etc/hosts

---

127.0.0.1 localhost nc.you.com lool.you.com

127.0.1.1 nc.you.com lool.you.com

---




Redis インストール

apt install redis-server -y

vi /etc/redis/redis.conf
---
supervised systemd
maxmemory 16mb
maxmemory-policy volatile-lfu
unixsocket /var/run/redis/redis-server.sock
unixsocketperm 777
timeout 60
---

usermod -a -G redis www-data

systemctl enable redis-server
systemctl restart redis.service
systemctl status redis-server

Shell







xxxxxxxxxx



 

apt install redis-server -y

​

vi /etc/redis/redis.conf

---

supervised systemd

maxmemory 16mb

maxmemory-policy volatile-lfu

unixsocket /var/run/redis/redis-server.sock

unixsocketperm 777

timeout 60

---

​

usermod -a -G redis www-data

​

systemctl enable redis-server

systemctl restart redis.service

systemctl status redis-server




その他インストール

# 入っていない場合に備えて
apt install -y cron vim build-essential
systemctl start cron
systemctl enable cron

Shell







xxxxxxxxxx



 

# 入っていない場合に備えて

apt install -y cron vim build-essential

systemctl start cron

systemctl enable cron





OPENLITESPEED PORT 80 + LETSENCRYPT

OpenLiteSpeed + php 8.1 インストール

wget -O - https://repo.litespeed.sh > enable_lst_debian_repo.sh
bash enable_lst_debian_repo.sh

apt update
apt install openlitespeed -y

systemctl status lshttpd
systemctl enable lshttpd
systemctl start lshttpd

# 公開フォルダ作成
mkdir /var/www/{nextcloud,80}
chown -R www-data:www-data /var/www/

# vertual hostの設定保存先
mkdir -p /usr/local/lsws/conf/vhosts/{nextcloud,httpPort,loolProxy}
chown www-data:www-data /usr/local/lsws/conf/vhosts/{nextcloud,httpPort,loolProxy}

# vertual hostのrootフォルダー
mkdir -p /usr/local/lsws/vhosts/{nextcloud,httpPort,loolProxy}
chown www-data:www-data /usr/local/lsws/vhosts/{nextcloud,httpPort,loolProxy}

# PHP 8.1 
apt install -y lsphp81 lsphp81-curl lsphp81-dev lsphp81-mysql lsphp81-redis lsphp81-apcu lsphp81-intl lsphp81-imagick

# php-imagickの警告削除のため。
apt install -y libmagickcore-6.q16-6-extra

# 設定ファイル 変更部分のみ
vi /usr/local/lsws/conf/httpd_config.conf
---
serverName                        nc.you.com
#user                             nobody
#group                            nogroup
user                             www-data
group                            www-data
#indexFiles                       index.html, index.php
indexFiles                       index.html, index.php, index.htm
#path                    lsphp73/bin/lsphp
path                    lsphp81/bin/lsphp
---

# 実行ユーザを変更した場合、必ず再インストール
apt -y install --reinstall openlitespeed

# 管理画面へのパスワード設定
/usr/local/lsws/admin/misc/admpass.sh

User name [admin]: your Name

Password: yourPassword
Retype password: yourPassword

# ramディスク作成
mkdir /tmp/ram
mount -t tmpfs -o size=8m /dev/shm /tmp/ram

vi /etc/fstab
---
tmpfs /tmp/ram tmpfs defaults,noatime,size=8m 0 0
---

# php設定 変更部分のみ
vi /usr/local/lsws/lsphp81/etc/php/8.1/litespeed/php.ini
---
memory_limit = 512M
upload_max_filesize = 64M
max_file_uploads = 100
post_max_size = 40M
output_buffering = Off

date.timezone = "Asia/Tokyo"

[Pdo_mysql]
# 環境に合わせて
pdo_mysql.default_socket = /var/run/mysqld/mysqld.sock

[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=32
opcache.max_accelerated_files=1000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1

opcache.jit=on
opcache.jit_buffer_size=128M

apc.enabled=1
apc.enable_cli = 1
apc.shm_size=64M
apc.ttl=3600
apc.gc_ttl=3600
---

# デフォルトユーザnobodyで作られるので一旦削除
rm -rf /tmp/lshttpd

# openLiteSpeed adminパネルの設定
vi /usr/local/lsws/admin/conf/admin_config.conf
---
# 以下の個所を以下のように修正
listener adminListener {
  address               *:7080
  secure                0
  keyFile                 /etc/letsencrypt/live/nc.you.com/privkey.pem
  certFile                /etc/letsencrypt/live/nc.you.com/fullchain.pem
  clientVerify          0
}
---

systemctl restart lshttpd

# www-dataでphpを簡単に扱えるように.bashrcのaliasを追加
su - www-data
vi ~/.bash_profile
---
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
---

vi ~/.bashrc
---
alias lsphp='/usr/local/lsws/lsphp81/bin/php -c /usr/local/lsws/lsphp81/etc/php/8.1/litespeed/php.ini'
---
source ~/.bashrc
exit

# rootユーザも
vi ~/.bashrc
---
# 以下1行を追加
alias lsphp='/usr/local/lsws/lsphp81/bin/php -c /usr/local/lsws/lsphp81/etc/php/8.1/litespeed/php.ini'
---
source ~/.bashrc

Shell







xxxxxxxxxx



 

wget -O - https://repo.litespeed.sh > enable_lst_debian_repo.sh

bash enable_lst_debian_repo.sh

​

apt update

apt install openlitespeed -y

​

systemctl status lshttpd

systemctl enable lshttpd

systemctl start lshttpd

​

# 公開フォルダ作成

mkdir /var/www/{nextcloud,80}

chown -R www-data:www-data /var/www/

​

# vertual hostの設定保存先

mkdir -p /usr/local/lsws/conf/vhosts/{nextcloud,httpPort,loolProxy}

chown www-data:www-data /usr/local/lsws/conf/vhosts/{nextcloud,httpPort,loolProxy}

​

# vertual hostのrootフォルダー

mkdir -p /usr/local/lsws/vhosts/{nextcloud,httpPort,loolProxy}

chown www-data:www-data /usr/local/lsws/vhosts/{nextcloud,httpPort,loolProxy}

​

# PHP 8.1 

apt install -y lsphp81 lsphp81-curl lsphp81-dev lsphp81-mysql lsphp81-redis lsphp81-apcu lsphp81-intl lsphp81-imagick

​

# php-imagickの警告削除のため。

apt install -y libmagickcore-6.q16-6-extra

​

# 設定ファイル 変更部分のみ

vi /usr/local/lsws/conf/httpd_config.conf

---

serverName                        nc.you.com

#user                             nobody

#group                            nogroup

user                             www-data

group                            www-data

#indexFiles                       index.html, index.php

indexFiles                       index.html, index.php, index.htm

#path                    lsphp73/bin/lsphp

path                    lsphp81/bin/lsphp

---

​

# 実行ユーザを変更した場合、必ず再インストール

apt -y install --reinstall openlitespeed

​

# 管理画面へのパスワード設定

/usr/local/lsws/admin/misc/admpass.sh

​

User name [admin]: your Name

​

Password: yourPassword

Retype password: yourPassword

​

# ramディスク作成

mkdir /tmp/ram

mount -t tmpfs -o size=8m /dev/shm /tmp/ram

​

vi /etc/fstab

---

tmpfs /tmp/ram tmpfs defaults,noatime,size=8m 0 0

---

​

# php設定 変更部分のみ

vi /usr/local/lsws/lsphp81/etc/php/8.1/litespeed/php.ini

---

memory_limit = 512M

upload_max_filesize = 64M

max_file_uploads = 100

post_max_size = 40M

output_buffering = Off

​

date.timezone = "Asia/Tokyo"

​

[Pdo_mysql]

# 環境に合わせて

pdo_mysql.default_socket = /var/run/mysqld/mysqld.sock

​

[opcache]

opcache.enable=1

opcache.enable_cli=1

opcache.interned_strings_buffer=32

opcache.max_accelerated_files=1000

opcache.memory_consumption=128

opcache.save_comments=1

opcache.revalidate_freq=1

​

opcache.jit=on

opcache.jit_buffer_size=128M

​

apc.enabled=1

apc.enable_cli = 1

apc.shm_size=64M

apc.ttl=3600

apc.gc_ttl=3600

---

​

# デフォルトユーザnobodyで作られるので一旦削除

rm -rf /tmp/lshttpd

​

# openLiteSpeed adminパネルの設定

vi /usr/local/lsws/admin/conf/admin_config.conf

---

# 以下の個所を以下のように修正

listener adminListener {

  address               *:7080

  secure                0

  keyFile                 /etc/letsencrypt/live/nc.you.com/privkey.pem

  certFile                /etc/letsencrypt/live/nc.you.com/fullchain.pem

  clientVerify          0

}

---

​

systemctl restart lshttpd

​

# www-dataでphpを簡単に扱えるように.bashrcのaliasを追加

su - www-data

vi ~/.bash_profile

---

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

---

​

vi ~/.bashrc

---

alias lsphp='/usr/local/lsws/lsphp81/bin/php -c /usr/local/lsws/lsphp81/etc/php/8.1/litespeed/php.ini'

---

source ~/.bashrc

exit

​

# rootユーザも

vi ~/.bashrc

---

# 以下1行を追加

alias lsphp='/usr/local/lsws/lsphp81/bin/php -c /usr/local/lsws/lsphp81/etc/php/8.1/litespeed/php.ini'

---

source ~/.bashrc




http://nc.you.com:7080/にアクセスし、port80が動くようにする。
ファイルから設定する場合は以下。

vi /usr/local/lsws/conf/httpd_config.conf
---
# 追加する。
virtualhost httpPort {
  vhRoot                  $SERVER_ROOT/vhosts/$VH_NAME/
  configFile              $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf
  allowSymbolLink         1
  enableScript            0
  restrained              1
}
# 修正する。
listener Default {
  address                 *:80
  secure                  0
  map                     httpPort nc.you.com, lool.you.com
}
---

# 新規作成
vi /usr/local/lsws/conf/vhosts/httpPort/vhconf.conf
---
docRoot                   /var/www/80/

errorlog $SERVER_ROOT/logs/$VH_NAME_error.log {
  useServer               0
  logLevel                ERROR
  rollingSize             10k
  keepDays                90
}

accesslog $SERVER_ROOT/logs/$VH_NAME_access.log {
  useServer               0
  logFormat               %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"
  rollingSize             10k
  keepDays                90
}
---
chown lsadm:www-data /usr/local/lsws/conf/vhosts/httpPort/vhconf.conf

Shell







xxxxxxxxxx



 

vi /usr/local/lsws/conf/httpd_config.conf

---

# 追加する。

virtualhost httpPort {

  vhRoot                  $SERVER_ROOT/vhosts/$VH_NAME/

  configFile              $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf

  allowSymbolLink         1

  enableScript            0

  restrained              1

}

# 修正する。

listener Default {

  address                 *:80

  secure                  0

  map                     httpPort nc.you.com, lool.you.com

}

---

​

# 新規作成

vi /usr/local/lsws/conf/vhosts/httpPort/vhconf.conf

---

docRoot                   /var/www/80/

​

errorlog $SERVER_ROOT/logs/$VH_NAME_error.log {

  useServer               0

  logLevel                ERROR

  rollingSize             10k

  keepDays                90

}

​

accesslog $SERVER_ROOT/logs/$VH_NAME_access.log {

  useServer               0

  logFormat               %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"

  rollingSize             10k

  keepDays                90

}

---

chown lsadm:www-data /usr/local/lsws/conf/vhosts/httpPort/vhconf.conf




LetsEncrypt (メールアドレス部分は変更のこと)

apt install certbot -y

# メールアドレスは自分のものに変更のこと
certbot certonly --non-interactive --agree-tos -m yourmail@mail.com --webroot -w /var/www/80/ -d nc.you.com -d lool.you.com

vi /etc/cron.d/certbot
---
# 変更
#0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew
0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew --deploy-hook "systemctl restart lshttpd"
---


Shell







xxxxxxxxxx



 

apt install certbot -y

​

# メールアドレスは自分のものに変更のこと

certbot certonly --non-interactive --agree-tos -m yourmail@mail.com --webroot -w /var/www/80/ -d nc.you.com -d lool.you.com

​

vi /etc/cron.d/certbot

---

# 変更

#0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew

0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew --deploy-hook "systemctl restart lshttpd"

---

​





OPENLITESPEED ADMIN設定

https://nc.you.com:7080/にアクセス可能なように変更。

vi /usr/local/lsws/admin/conf/admin_config.conf
---
listener adminListener {
  address               *:7080
  # この行から下3行を変更
  secure                1
  keyFile                 /etc/letsencrypt/live/nc.you.com/privkey.pem
  certFile                /etc/letsencrypt/live/nc.you.com/fullchain.pem
  clientVerify          0
}
---


Shell







xxxxxxxxxx



 

vi /usr/local/lsws/admin/conf/admin_config.conf

---

listener adminListener {

  address               *:7080

  # この行から下3行を変更

  secure                1

  keyFile                 /etc/letsencrypt/live/nc.you.com/privkey.pem

  certFile                /etc/letsencrypt/live/nc.you.com/fullchain.pem

  clientVerify          0

}

---

​




https://nc.you.com:7080/にアクセスし、以下を変更

[一般タブ] 統計出力ディレクトリ => /tmp/ram/
[一般タブ] 自動インデックス => いいえ
[ログタブ] ログレベル => WARNING
[外部アプリケーション] LiteSpeed SAPI を以下のように編集
 最大接続数 => 200
 環境の「PHP_LSAPI_CHILDREN」の値を200に変更

ファイルから変更する場合は以下

vi /usr/local/lsws/conf/httpd_config.conf
---
# 上部のグローバルなエリア(user/groupの設定)のあたりに追加
statDir                   /tmp/ram/

# 真ん中ぐらい・・
indexFiles                index.html, index.phpi, index.htm
autoIndex                 0

# このセクションの以下3行をなければ追加、あれば修正
extprocessor lsphp {
  maxConns                200
  env                     PHP_LSAPI_CHILDREN=200
  env                     LSAPI_AVOID_FORK=200M
}
---


Shell







xxxxxxxxxx



 

vi /usr/local/lsws/conf/httpd_config.conf

---

# 上部のグローバルなエリア(user/groupの設定)のあたりに追加

statDir                   /tmp/ram/

​

# 真ん中ぐらい・・

indexFiles                index.html, index.phpi, index.htm

autoIndex                 0

​

# このセクションの以下3行をなければ追加、あれば修正

extprocessor lsphp {

  maxConns                200

  env                     PHP_LSAPI_CHILDREN=200

  env                     LSAPI_AVOID_FORK=200M

}

---

​





NEXTCLOUDインストール

ソースをダウンロードし配置。

mkdir ~/src/
cd ~/src/

# 環境は最新のものを選んで。以下は24.0.4のケース
wget https://download.nextcloud.com/server/releases/nextcloud-24.0.4.tar.bz2
tar xf nextcloud-24.0.4.tar.bz2
cp -r ./nextcloud/. /var/www/nextcloud/

mkdir /var/www/nextcloud/{data,.well-known}
mkdir /var/www/nextcloud/.well-known/{carddav,caldav,webfinger,nodeinfo}

chown -R www-data:www-data /var/www/nextcloud/

Shell







xxxxxxxxxx



 

mkdir ~/src/

cd ~/src/

​

# 環境は最新のものを選んで。以下は24.0.4のケース

wget https://download.nextcloud.com/server/releases/nextcloud-24.0.4.tar.bz2

tar xf nextcloud-24.0.4.tar.bz2

cp -r ./nextcloud/. /var/www/nextcloud/

​

mkdir /var/www/nextcloud/{data,.well-known}

mkdir /var/www/nextcloud/.well-known/{carddav,caldav,webfinger,nodeinfo}

​

chown -R www-data:www-data /var/www/nextcloud/




NextCloud configファイル設定(追加/修正箇所のみ。最後の2行は.htaccessの更新用)

vi /var/www/nextcloud/config/config.php
---
# 修正箇所のみ
$CONFIG = array (
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'overwrite.cli.url' => 'https://nc.you.com/',
  'htaccess.RewriteBase' => '/',
---

Shell







xxxxxxxxxx



 

vi /var/www/nextcloud/config/config.php

---

# 修正箇所のみ

$CONFIG = array (

  'memcache.local' => '\\OC\\Memcache\\APCu',

  'memcache.distributed' => '\\OC\\Memcache\\Redis',

  'redis' =>

  array (

    'host' => '/var/run/redis/redis-server.sock',

    'port' => 0,

    'timeout' => 0.0,

  ),

  'memcache.locking' => '\\OC\\Memcache\\Redis',

  'overwrite.cli.url' => 'https://nc.you.com/',

  'htaccess.RewriteBase' => '/',

---




.htaccessを以下のコマンドで更新

su - www-data
lsphp /var/www/nextcloud/occ maintenance:update:htaccess
exit


Shell







xxxxxxxxxx



 

su - www-data

lsphp /var/www/nextcloud/occ maintenance:update:htaccess

exit

​




生成された、/var/www/nextcloud/.htaccess ファイルを開き、何か所かある<IfModule
mod_rewrite.c>のセクションを下のOpenLiteSpeedのvirtual hostのrewrite =>
rulesに追加。(下の設定ファイルを参考のほど。最初2行:RewriteRule ^/data/.*$ – [F,L]とRewriteRule
^/config/.*$ – [F,L]の下に追加する。RewriteEngine
onやmod_envのセクションが内部に含まれる場合はその箇所はコピーしないこと。またRewriteRuleの先頭が^のものは^/に変更すること。.htaccessに限り、Apacheと記述ルールが若干違う。)

OpenLiteSpeedにvirtual hostを設定

vi /usr/local/lsws/conf/httpd_config.conf
---
# お尻のほうに以下を追加
virtualhost nextcloud {
  vhRoot                  $SERVER_ROOT/vhosts/$VH_NAME/
  configFile              $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf
  allowSymbolLink         1
  enableScript            1
  restrained              1
}

listener nextcloud {
  address                 *:443
  secure                  1
  keyFile                 /etc/letsencrypt/live/nc.you.com/privkey.pem
  certFile                /etc/letsencrypt/live/nc.you.com/fullchain.pem
  map                     nextcloud nc.you.com
}
---

vi /usr/local/lsws/conf/vhosts/nextcloud/vhconf.conf
---
docRoot                   /var/www/nextcloud/
enableGzip                1

errorlog $SERVER_ROOT/logs/nextcloud_error.log {
  useServer               0
  logLevel                ERROR
  rollingSize             10M
  keepDays                30
}

accesslog $SERVER_ROOT/logs/nextcloud_access.log {
  useServer               0
  logFormat               %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"
  rollingSize             10M
  keepDays                30
}

index  {
  useServer               0
}
errorpage 403 {
  url                     /
}

errorpage 404 {
  url                     /
}
context / {
  allowBrowse             1
  extraHeaders            Strict-Transport-Security "max-age=15552000; includeSubDomains;preload"

  rewrite  {

  }
  addDefaultCharset       off

  phpIniOverride  {

  }
}
rewrite  {
  enable                  1
  autoLoadHtaccess        0
  rules                   <<<END_rules
RewriteRule ^/data/.*$ - [F,L]
RewriteRule ^/config/.*$ - [F,L]

RewriteCond %{HTTP_USER_AGENT} DavClnt
RewriteRule ^$ /remote.php/webdav/ [L,R=302]
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^/\.well-known/carddav /remote.php/dav/ [R=301,L]
RewriteRule ^/\.well-known/caldav /remote.php/dav/ [R=301,L]
RewriteRule ^/remote/(.*) remote.php [QSA,L]
RewriteRule ^/(?:build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
RewriteRule ^/\.well-known/(?!acme-challenge|pki-validation) /index.php [QSA,L]
RewriteRule ^/(?:\.(?!well-known)|autotest|occ|issue|indie|db_|console).* - [R=404,L]

RewriteRule ^/core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]
RewriteRule ^/core/preview.png$ index.php [PT,E=PATH_INFO:$1]
RewriteCond %{REQUEST_FILENAME} !\.(css|js|svg|gif|png|html|ttf|woff2?|ico|jpg|jpeg|map|webm|mp4|mp3|ogg|wav|wasm|tflite)$
RewriteCond %{REQUEST_FILENAME} !/core/ajax/update\.php
RewriteCond %{REQUEST_FILENAME} !/core/img/(favicon\.ico|manifest\.json)$
RewriteCond %{REQUEST_FILENAME} !/(cron|public|remote|status)\.php
RewriteCond %{REQUEST_FILENAME} !/ocs/v(1|2)\.php
RewriteCond %{REQUEST_FILENAME} !/robots\.txt
RewriteCond %{REQUEST_FILENAME} !/(ocm-provider|ocs-provider|updater)/
RewriteCond %{REQUEST_URI} !^/\.well-known/(acme-challenge|pki-validation)/.*
RewriteCond %{REQUEST_FILENAME} !/richdocumentscode(_arm64)?/proxy.php$
RewriteRule . index.php [PT,E=PATH_INFO:$1]
  END_rules
}
---

# check the config files
/usr/local/lsws/bin/openlitespeed -t

systemctl restart lshttpd


Shell







xxxxxxxxxx



 

vi /usr/local/lsws/conf/httpd_config.conf

---

# お尻のほうに以下を追加

virtualhost nextcloud {

  vhRoot                  $SERVER_ROOT/vhosts/$VH_NAME/

  configFile              $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf

  allowSymbolLink         1

  enableScript            1

  restrained              1

}

​

listener nextcloud {

  address                 *:443

  secure                  1

  keyFile                 /etc/letsencrypt/live/nc.you.com/privkey.pem

  certFile                /etc/letsencrypt/live/nc.you.com/fullchain.pem

  map                     nextcloud nc.you.com

}

---

​

vi /usr/local/lsws/conf/vhosts/nextcloud/vhconf.conf

---

docRoot                   /var/www/nextcloud/

enableGzip                1

​

errorlog $SERVER_ROOT/logs/nextcloud_error.log {

  useServer               0

  logLevel                ERROR

  rollingSize             10M

  keepDays                30

}

​

accesslog $SERVER_ROOT/logs/nextcloud_access.log {

  useServer               0

  logFormat               %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"

  rollingSize             10M

  keepDays                30

}

​

index  {

  useServer               0

}

errorpage 403 {

  url                     /

}

​

errorpage 404 {

  url                     /

}

context / {

  allowBrowse             1

  extraHeaders            Strict-Transport-Security "max-age=15552000; includeSubDomains;preload"

​

  rewrite  {

​

  }

  addDefaultCharset       off

​

  phpIniOverride  {

​

  }

}

rewrite  {

  enable                  1

  autoLoadHtaccess        0

  rules                   <<<END_rules

RewriteRule ^/data/.*$ - [F,L]

RewriteRule ^/config/.*$ - [F,L]

​

RewriteCond %{HTTP_USER_AGENT} DavClnt

RewriteRule ^$ /remote.php/webdav/ [L,R=302]

RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteRule ^/\.well-known/carddav /remote.php/dav/ [R=301,L]

RewriteRule ^/\.well-known/caldav /remote.php/dav/ [R=301,L]

RewriteRule ^/remote/(.*) remote.php [QSA,L]

RewriteRule ^/(?:build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]

RewriteRule ^/\.well-known/(?!acme-challenge|pki-validation) /index.php [QSA,L]

RewriteRule ^/(?:\.(?!well-known)|autotest|occ|issue|indie|db_|console).* - [R=404,L]

​

RewriteRule ^/core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]

RewriteRule ^/core/preview.png$ index.php [PT,E=PATH_INFO:$1]

RewriteCond %{REQUEST_FILENAME} !\.(css|js|svg|gif|png|html|ttf|woff2?|ico|jpg|jpeg|map|webm|mp4|mp3|ogg|wav|wasm|tflite)$

RewriteCond %{REQUEST_FILENAME} !/core/ajax/update\.php

RewriteCond %{REQUEST_FILENAME} !/core/img/(favicon\.ico|manifest\.json)$

RewriteCond %{REQUEST_FILENAME} !/(cron|public|remote|status)\.php

RewriteCond %{REQUEST_FILENAME} !/ocs/v(1|2)\.php

RewriteCond %{REQUEST_FILENAME} !/robots\.txt

RewriteCond %{REQUEST_FILENAME} !/(ocm-provider|ocs-provider|updater)/

RewriteCond %{REQUEST_URI} !^/\.well-known/(acme-challenge|pki-validation)/.*

RewriteCond %{REQUEST_FILENAME} !/richdocumentscode(_arm64)?/proxy.php$

RewriteRule . index.php [PT,E=PATH_INFO:$1]

  END_rules

}

---

​

# check the config files

/usr/local/lsws/bin/openlitespeed -t

​

systemctl restart lshttpd

​





COLLABOLA ONLINEインストール

インストール

cd /usr/share/keyrings
sudo wget https://collaboraoffice.com/downloads/gpg/collaboraonline-release-keyring.gpg

# ファイル作成
vi /etc/apt/sources.list.d/collaboraonline.sources
---
Types: deb
URIs: https://www.collaboraoffice.com/repos/CollaboraOnline/CODE-ubuntu2204
Suites: ./
Signed-By: /usr/share/keyrings/collaboraonline-release-keyring.gpg
---

# インストール
apt update
apt install coolwsd code-brand -y

# 設定
loolconfig set ssl.enable false
loolconfig set ssl.termination true
loolconfig set storage.wopi.host nc.you.com
loolconfig set server_name lool.you.com

# adminパスワードを設定
loolconfig set-admin-password

# 設定ファイル修正
vi /etc/coolwsd/coolwsd.xml
---
# 修正は3か所
# net.protoをipv4のみに変更
# num_prespawn_childrenを10に変更
# allowed_languagesをen_USのみに変更
---

systemctl enable coolwsd
systemctl start coolwsd

# 動作しているか確認
systemctl status coolwsd

Shell







xxxxxxxxxx



 

cd /usr/share/keyrings

sudo wget https://collaboraoffice.com/downloads/gpg/collaboraonline-release-keyring.gpg

​

# ファイル作成

vi /etc/apt/sources.list.d/collaboraonline.sources

---

Types: deb

URIs: https://www.collaboraoffice.com/repos/CollaboraOnline/CODE-ubuntu2204

Suites: ./

Signed-By: /usr/share/keyrings/collaboraonline-release-keyring.gpg

---

​

# インストール

apt update

apt install coolwsd code-brand -y

​

# 設定

loolconfig set ssl.enable false

loolconfig set ssl.termination true

loolconfig set storage.wopi.host nc.you.com

loolconfig set server_name lool.you.com

​

# adminパスワードを設定

loolconfig set-admin-password

​

# 設定ファイル修正

vi /etc/coolwsd/coolwsd.xml

---

# 修正は3か所

# net.protoをipv4のみに変更

# num_prespawn_childrenを10に変更

# allowed_languagesをen_USのみに変更

---

​

systemctl enable coolwsd

systemctl start coolwsd

​

# 動作しているか確認

systemctl status coolwsd




OpenLiteSpeedにvirtual hostを設定 (Reverse Proxyを設定 WebSocketも)

vi /usr/local/lsws/conf/httpd_config.conf
---
# お尻のほうに以下を追加
virtualhost loolProxy {
  vhRoot                  $SERVER_ROOT/vhosts/$VH_NAME/
  configFile              $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf
  allowSymbolLink         1
  enableScript            1
  restrained              1
}

# 以下の箇所は修正(最後の1行を追加)
listener nextcloud {
  address                 *:443
  secure                  1
  keyFile                 /etc/letsencrypt/live/nc.you.com/privkey.pem
  certFile                /etc/letsencrypt/live/nc.you.com/fullchain.pem
  map                     nextcloud nc.you.com
  map                     loolProxy lool.you.com  
}
---

vi /usr/local/lsws/conf/vhosts/loolProxy/vhconf.conf
---
docRoot                   /var/www/80

errorlog $SERVER_ROOT/logs/$VH_NAME_error.log {
  useServer               0
  logLevel                ERROR
  rollingSize             10M
  keepDays                30
}

accesslog $SERVER_ROOT/logs/$VH_NAME_access.log {
  useServer               0
  logFormat               %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"
  rollingSize             10M
  keepDays                30
}

extprocessor lool {
  type                    proxy
  address                 127.0.0.1:9980
  maxConns                100
  pcKeepAliveTimeout      60
  initTimeout             60
  retryTimeout            0
  respBuffer              0
}

context / {
  type                    proxy
  handler                 lool
  addDefaultCharset       off
}

websocket / {
  address                 127.0.0.1:9980
}
---


Shell







xxxxxxxxxx



 

vi /usr/local/lsws/conf/httpd_config.conf

---

# お尻のほうに以下を追加

virtualhost loolProxy {

  vhRoot                  $SERVER_ROOT/vhosts/$VH_NAME/

  configFile              $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf

  allowSymbolLink         1

  enableScript            1

  restrained              1

}

​

# 以下の箇所は修正(最後の1行を追加)

listener nextcloud {

  address                 *:443

  secure                  1

  keyFile                 /etc/letsencrypt/live/nc.you.com/privkey.pem

  certFile                /etc/letsencrypt/live/nc.you.com/fullchain.pem

  map                     nextcloud nc.you.com

  map                     loolProxy lool.you.com  

}

---

​

vi /usr/local/lsws/conf/vhosts/loolProxy/vhconf.conf

---

docRoot                   /var/www/80

​

errorlog $SERVER_ROOT/logs/$VH_NAME_error.log {

  useServer               0

  logLevel                ERROR

  rollingSize             10M

  keepDays                30

}

​

accesslog $SERVER_ROOT/logs/$VH_NAME_access.log {

  useServer               0

  logFormat               %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"

  rollingSize             10M

  keepDays                30

}

​

extprocessor lool {

  type                    proxy

  address                 127.0.0.1:9980

  maxConns                100

  pcKeepAliveTimeout      60

  initTimeout             60

  retryTimeout            0

  respBuffer              0

}

​

context / {

  type                    proxy

  handler                 lool

  addDefaultCharset       off

}

​

websocket / {

  address                 127.0.0.1:9980

}

---

​





最後に

これでNextCloudとCollabora onlineが動作するはずである。

https://nc.you.com/にアクセスし、初期設定を行った後、管理者の[オフィス]設定から、[自前のサーバを使用する]をチェックし、「https://lool.you.com/」を設定すればExcelなどのオフィスファイルがブラウザで開けるようになる。

NextCloudの初期設定では、推奨アプリを入れるか聞かれるが、推奨アプリは入れず、後から、Nextcloud
officeアプリだけ入れることをお勧めする。要らないアプリを要れないことでNextCloudは軽くなる。

その他、NextCloudが重たくなる設定ポイントがいくつあるが、[共有]設定のクラウド共有関係はすべてチェックを外すと履歴関係は軽くなる。あとはDBが同じサーバにあるなら、configのdbhostを「127.0.0.1:/var/run/mysqld/mysqld.sock」でソケットに直接アクセスさせるなども有効。

セキュリティが気になるなら、ufwとfail2banで不正なログインがあったらアクセス禁止にする対策をする。

記載はしなかったが、



--------------------------------------------------------------------------------

← Outlookのフォルダ構成ごとメールを取り出す方法 → NextCloudで日本語(Shift-JIS)のテキストファイルを開く(簡単 1ファイル修正)

--------------------------------------------------------------------------------


最近の投稿

 * Update後にCollabora Onlineが動かなくなる
 * FreeBSD 13 Apacheの再起動が失敗する
 * FreeBSD 13.xでsshfsが動かない (解決)
 * PRIMERGY TX150 S7の分解、CPU換装/メモリ換装/HDD->SSD換装
 * システム改修:インボイス制度対応のまとめ

© 2024年 FlatterMe

上へ ↑ 上 ↑