LinuxServer

nextcloud

初回設定、参考サイト

Log出力設定の変更

参考サイト

ログの出力、確認

php (nextCloudのルートフォルダ)/occ log:file

ログの出力方式変更

php (nextCloudのルートフォルダ)/occ log:manage --level=info --timezone Asia/Tokyo

Install後のセキュリティ&セットアップ警告

「.soファイル」のコピー先の確認方法

OPcache

Install

sudo yum install php74-php-opcache php74-php-pecl-apcu

必要なファイルをApacheが参照しているディレクトリへコピー

  1. 必要なファイルの検索1
    find /opt -name "*opcache*"
  2. 必要なファイルの検索2
    find /etc -name "*opcache*"
  3. ファイルのコピー
    sudo cp /etc/opt/remi/php74/php.d/10-opcache.ini /etc/php.d/
    sudo cp /opt/remi/php74/root/usr/lib64/php/modules/opcache.so /usr/lib64/php/modules/

設定変更

  1. sudo vim /etc/php.d/10-opcache.ini
    zend_extension=opcache
    opcache.enable=1
    opcache.interned_strings_buffer=8
    opcache.max_accelerated_files=10000
    opcache.memory_consumption=128
    opcache.save_comments=1
    opcache.revalidate_freq = 60
    opcache.validate_timestamps = 0

確認

  1. php -v
    1. 結果例
      PHP 7.4.33 (cli) (built: Apr 10 2024 09:34:29) ( NTS )
      Copyright (c) The PHP Group
      Zend Engine v3.4.0, Copyright (c) Zend Technologies
          with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies
  2. phpinfoにも「Zend OPcache」の項目として出てきます

APCu

Install

sudo yum install php74-php-pecl-apcu

必要なファイルをApacheが参照しているディレクトリへコピー

  1. 必要なファイルの検索1
    find /opt -name "*apcu*"
  2. 必要なファイルの検索2
    find /etc -name "*apcu*"
  3. ファイルのコピー
    sudo cp /etc/opt/remi/php74/php.d/40-apcu.ini /etc/php.d/
    sudo cp /opt/remi/php74/root/usr/lib64/php/modules/apcu.so /usr/lib64/php/modules/

設定変更

  1. sudo vim (nextCloudのルートフォルダ)/config/config.php
    • 「'memcache.local' => '\OC\Memcache\APCu',」を追加
        'installed' => true,                                                                                                    │
        'default_phone_region' => 'JP',                                                                                         │
        'memcache.local' => '\OC\Memcache\APCu',                                                                                │
        'memcache.distributed' => '\OC\Memcache\Redis',                                                                         │
        'memcache.locking' => '\OC\Memcache\Redis',                                                                             │
        'redis' => [                                                                                                            │
             'host' => 'localhost',                                                                                             │
             'port' => 6379,                                                                                                    │
        ],                                                                                                                      │
      );    

確認

  1. httpdを再起動
    sudo systemctl restart httpd
  2. phpinfoに「apcu」の項目として出てきます。

redis

Install

sudo yum install php74-php-pecl-redis

必要なファイルをApacheが参照しているディレクトリへコピー

  1. redis関連
    1. 必要なファイルの検索1
      find /opt -name "*redis.so*"
    2. 必要なファイルの検索2
      find /etc -name "*redis*"
    3. ファイルのコピー
      sudo cp /etc/opt/remi/php74/php.d/50-redis.ini /etc/php.d/
      sudo cp /opt/remi/php74/root/usr/lib64/php/modules/redis.so /usr/lib64/php/modules/
  2. igbinary.so
    1. 必要なファイルの検索1
      find /opt -name "*igbinary*"
    2. 必要なファイルの検索2
      find /etc -name "*igbinary*"
    3. ファイルのコピー
      sudo cp /etc/opt/remi/php74/php.d/40-igbinary.ini /etc/php.d/
      sudo cp /opt/remi/php74/root/usr/lib64/php/modules/igbinary.so /usr/lib64/php/modules/
  3. msgpack.so
    1. 必要なファイルの検索1
      find /opt -name "*msgpack*"
    2. 必要なファイルの検索2
      find /etc -name "*msgpack*"
    3. ファイルのコピー
      sudo cp /etc/opt/remi/php74/php.d/40-msgpack.ini /etc/php.d/
      sudo cp /opt/remi/php74/root/usr/lib64/php/modules/msgpack.so /usr/lib64/php/modules/

設定変更

  1. sudo vim (nextCloudのルートフォルダ)/config/config.php
    • 「'memcache.distributed' => '\OC\Memcache\Redis',」以下を追加
        'installed' => true,
        'default_phone_region' => 'JP',
        'memcache.local' => '\OC\Memcache\APCu',
        'memcache.distributed' => '\OC\Memcache\Redis',
        'memcache.locking' => '\OC\Memcache\Redis',
        'redis' => [
             'host' => 'localhost',
             'port' => 6379,
        ],
      );

確認

  1. httpdを再起動
    sudo systemctl restart httpd
  2. phpinfoに「redis」の項目として出てきます。

OPcacheのインターン化文字列バッファーがまもなく一杯になります。全てのスクリプトをキャッシュに保管できるようにするには、opcache.interned_strings_bufferの値を8より多い値で、PHP設定に適用することを推奨します。

php-fpm のチューニング

全文検索機能を組み込む(elasticsearch,Full text search)

環境

elasticsearchサーバの構築

install

  1. レポジトリkeyのインストール
    wget https://artifacts.elastic.co/GPG-KEY-elasticsearch -O /etc/apt/keyrings/GPG-KEY-elasticsearch.key
    echo "deb [signed-by=/etc/apt/keyrings/GPG-KEY-elasticsearch.key] https://artifacts.elastic.co/packages/8.x/apt stable main" | tee /etc/apt/sources.list.d/elastic-8.x.list 
  2. 関連パッケージのインストール(ただあとでsslは無効化するので不要かも。。。)
    sudo apt-get install apt-transport-https
  3. install
    sudo apt update
    apt -y install elasticsearch
  4. アナライザ トークナイザ、「analysis-kuromoji」のインストール
    sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-kuromoji

メモリ関連の設定

sudo vim /etc/elasticsearch/jvm.options 
  1. 以下を追加(値は各自のサーバ状況に合わせて下さい)
    ################################################################
    ## IMPORTANT: JVM heap size
    ################################################################
    ##
    ## The heap size is automatically configured by Elasticsearch
    ## based on the available memory in your system and the roles
    ## each node is configured to fulfill. If specifying heap is
    ## required, it should be done through a file in jvm.options.d,
    ## which should be named with .options suffix, and the min and
    ## max should be set to the same value. For example, to set the
    ## heap to 4 GB, create a new file in the jvm.options.d
    ## directory containing these lines:
    ##
    ## -Xms4g
    ## -Xmx4g
    ##
    ## See https://www.elastic.co/guide/en/elasticsearch/reference/8.17/heap-size.html
    ## for more information
    ##
    ################################################################
    
    -Xms1g
    -Xmx2g

sslの無効化

sudo vim /etc/elasticsearch/elasticsearch.yml
# Enable security features
#xpack.security.enabled: true
xpack.security.enabled: false

#xpack.security.enrollment.enabled: true
xpack.security.enrollment.enabled: false

# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
#xpack.security.http.ssl:
#  enabled: true
#  keystore.path: certs/http.p12
#
xpack.security.http.ssl:
  enabled: false
#  keystore.path: certs/http.p12


# Enable encryption and mutual authentication between cluster nodes
#xpack.security.transport.ssl:
#  enabled: true
#  verification_mode: certificate
#  keystore.path: certs/transport.p12
#  truststore.path: certs/transport.p12

xpack.security.transport.ssl:
  enabled: false
#  verification_mode: certificate
#  keystore.path: certs/transport.p12
#  truststore.path: certs/transport.p12



# Create a new cluster with the current node only
# Additional nodes can still join the cluster later
cluster.initial_master_nodes: ["serverName"]

# Allow HTTP API connections from anywhere
# Connections are encrypted and require user authentication
http.host: 0.0.0.0

# Allow other nodes to join the cluster from anywhere
# Connections are encrypted and mutually authenticated
#transport.host: 0.0.0.0

#----------------------- END SECURITY AUTO CONFIGURATION -------------------------

elasticsearchデーモンの起動と自動起動設定

sudo systemctl restart elasticsearch 
sudo systemctl enable elasticsearch 

動作確認

  1. なんかしら帰ってきます。ブラウザでも確認可能。
    curl http://localhost:9200

nextcloud側の設定

関連アプリのインストール

  1. 右上のイニシャルボタンから「アプリ」を選択
    • nextCloudApp01.png
  2. 左側の「ダッシュボード」を選択し、上の検索から「full text」で検索
    下の画像の3つを有効にしてインストールします。
    • nextCloudApp02.png

設定

  1. 右上のイニシャル・アイコンから「管理者設定」を選択
    • nextCloudApp03.png
  2. 左側から全文検索を選択
    • nextCloudApp04.png
  3. 設定イメージ
    • nextCloudApp05.png
    • nextCloudApp06.png
  4. 設定値(コピペできるように)
    • http://localhost:9200/
    • nextcloud
      • これ、はまりました。。。この文字列でないとelasticsearchが動かないです。。。
    • analysis-kuromoji

全文検索、index作成テストと作成

その他

sessionディレクトリへ権限追加

sessionディレクトリの確認

sessionディレクトリへアクセス兼を設定

sudo chown apache: -R /var/lib/php/session

パスワード・リセット

sudo -u www-data php /var/www/nextcloud/occ user:resetpassword admin

WindowsのExplorer(エクスプローラー)でマウント

Apache実行ユーザーの変更

ログインできない

redis エラー

cron実行ユーザーの変更

エラー対処

参考サイト

cron.phpが実行されない

updateに失敗する(create backup failed)

  1. 以下のコマンドで確認
    sudo -u www-data php --define apc.enable_cli=1 /var/www/nextcloud/updater/updater.phar
  2. バックアップの失敗はpermissionエラーの場合が多い。
    以下のコマンドを実行
    sudo chown www-data:www-data -R /var/www/nextcloud/*

メンタンス・モード(Maintenanceモード)が解除されない。

  1. 以下のファイルを編集
    sudo vim /var/www/nextcloud/config/config.php
  2. 以下の場所
     'maintenance' => false,

Downgrading is not supported and is likely to cause unpredictable issues

  1. apacheの再起動
    sudo systemctl restart apache2

同期エラーで修正しようとしても「ローカルファイルコピー元のファイルが存在しません」となる

  1. NextCloud側にゴミが残っているので、ブラウザでNextCloudにアクセスし、当該ファイルを削除する。
    (F5キーなど最新の情報に更新するのを忘れずに。。。)

トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS