「Nextcloud」の版間の差分
(同期) |
Kusakata.bot (トーク | 投稿記録) 細 (文字列「Tips and tricks」を「ヒントとテクニック」に置換) |
||
(2人の利用者による、間の9版が非表示) | |||
1行目: | 1行目: | ||
− | {{lowercase title}} |
||
[[Category:ウェブサーバー]] |
[[Category:ウェブサーバー]] |
||
− | [[en: |
+ | [[en:Nextcloud]] |
[[fr:Owncloud]] |
[[fr:Owncloud]] |
||
{{Related articles start}} |
{{Related articles start}} |
||
{{Related|LAMP}} |
{{Related|LAMP}} |
||
+ | {{Related|LEMP}} |
||
{{Related|Nginx}} |
{{Related|Nginx}} |
||
{{Related|OpenSSL}} |
{{Related|OpenSSL}} |
||
{{Related|WebDAV}} |
{{Related|WebDAV}} |
||
{{Related articles end}} |
{{Related articles end}} |
||
+ | [[Wikipedia:ownCloud|Wikipedia]] より: |
||
− | [[Wikipedia:OwnCloud|ownCloud]] はクラウドストレージを提供するためのソフトウェア群です。 |
||
+ | :Nextcloud はファイルホストサービスを作成して使用するためのクライアントサーバーソフトウェアスイートである。広く使われている Dropbox と同じような機能を持ち、フリーでオープンソースであるため、誰でもプライベートサーバーにインストール・使用することができる。Dropbox などのプロプライエタリサービスと異なり、オープンなアーキテクチャを活用してサーバーに機能 (アプリケーション) を簡単に追加することが可能。 |
||
− | ownCloud のインストールと設定はどのウェブサーバーとデータベースを動かすかによって異なってきます。現在のところ wiki には [[#Apache の設定]] と [[#Nginx + uwsgi_php の設定]] が載っています。 |
||
+ | Nextcloud と ownCloud の違いについては [https://en.wikipedia.org/wiki/Nextcloud#Differences_from_ownCloud] を見てください。 |
||
− | == 必要環境 == |
||
+ | == 要件 == |
||
− | ''ownCloud'' は[[:Category:ウェブサーバー|ウェブサーバー]]と [[PHP]]、[[:Category:データベース管理システム|データベース]]を必要とします。古典的な [[LAMP]] の組み合わせで問題なく動作し、[https://doc.owncloud.org/server/8.1/admin_manual/release_notes.html#recommended-setup-for-running-owncloud 推奨] されています。 |
||
+ | Nextcloud は以下のコンポーネントを必要とします: |
||
+ | * ウェブサーバー: [[Apache]] または [[nginx]]。 |
||
+ | * データベース: [[MariaDB]] または [[PostgreSQL]]。 |
||
+ | * [[PHP]] と[[#PHP|追加モジュール]]。 |
||
+ | |||
+ | 先に進む前にまずは必要なコンポーネントをインストールしてください。 |
||
== インストール == |
== インストール == |
||
− | + | {{Pkg|nextcloud}} パッケージを[[インストール]]してください。 |
|
+ | == セットアップ == |
||
− | {{ic|/etc/php/php.ini}} で'''必要な'''以下のエクステンションをアンコメントします [https://doc.owncloud.org/server/8.2/admin_manual/installation/source_installation.html#prerequisites]: |
||
− | gd.so |
||
− | iconv.so |
||
− | xmlrpc.so |
||
− | zip.so |
||
+ | Nextcloud をセットアップするには PHP が動作するウェブサーバー・データベースサーバーが必要です。 |
||
− | また、{{Pkg|php-intl}} と {{Pkg|php-mcrypt}} をインストールして以下のエクステンションをアンコメントすることが [https://doc.owncloud.org/server/8.2/admin_manual/installation/source_installation.html#prerequisites 推奨] されています: |
||
− | bz2.so |
||
− | curl.so |
||
− | intl.so |
||
− | mcrypt.so |
||
− | === |
+ | === PHP の設定 === |
+ | {{Tip|必要な全ての PHP モジュールについては、上流のドキュメントを参照してください: [https://docs.nextcloud.com/server/11/admin_manual/installation/source_installation.html#prerequisites Nextcloud 11.0]。}} |
||
+ | [[PHP#gd]], {{pkg|php-intl}}, {{pkg|php-mcrypt}} を追加モジュールとしてインストールしてください。 |
||
− | パフォーマンスを向上させるために、APCu による PHP キャッシュを使うことを推奨します。[[PHP#APCu]] を見てください。同じく OPCache も有効にすると有益です。[[PHP#OPCache]] を参照。 |
||
+ | 使用するデータベースバックエンドに応じて設定が必要です: |
||
− | APCu を有効にした後、以下のディレクティブを {{ic|/etc/webapps/owncloud/config/config.php}} に追加してください: |
||
+ | * [[MySQL]] の場合、[[PHP#MySQL/MariaDB]] を見てください。 |
||
− | 'memcache.local' => '\OC\Memcache\APCu', |
||
+ | * [[PostgreSQL]] の場合、[[PHP#PostgreSQL]] を見てください。 |
||
+ | * [[SQLite]] の場合、[[PHP#Sqlite]] を見てください。 |
||
+ | [[PHP#キャッシュ|キャッシュ]]を活用することでパフォーマンスを改善することができます。詳しくは公式ドキュメントの [https://docs.nextcloud.com/server/11/admin_manual/configuration_server/caching_configuration.html メモリキャッシュの設定] を見てください。 |
||
− | {{Note| |
||
− | * [[PHP#設定|PHP 設定]]の {{ic|[apc]}} の下に {{ic|1=apc.enable_cli=1}} を追加してください。また、{{ic|/etc/php/conf.d/apcu.ini}} の {{ic|1=extension=apcu.so}} をアンコメントしてください。2015年7月12日現在、これらの設定をしないと [https://github.com/owncloud/core/issues/17329#issuecomment-119248944 複数] の [https://github.com/owncloud/documentation/issues/1233#issuecomment-120664134 問題] が発生します。 |
||
− | * 2016年1月4日現在、OwnCloud 8.2.2 では {{Pkg|php-apcu-bc}} パッケージに含まれている "APCu Backwards Compatibility Module" が必要です。パッケージをインストールしたら {{ic|/etc/php/conf.d/apcu.ini}} の {{ic|1=extension=apcu.so}} の後に {{ic|1=extension=apc.so}} を追加してください。}} |
||
+ | === データベースの設定 === |
||
− | 詳しくは [https://doc.owncloud.org/server/8.1/admin_manual/configuration_server/config_sample_php_parameters.html#memory-caching-backend-configuration 公式ドキュメント] を参照。 |
||
+ | Nextcloud を動かすには SQL データベースをセットアップする必要があります。データベースを設定したら、まずは管理者アカウントを作成する必要があります。 |
||
− | === /dev/urandom のアクセス === |
||
+ | ==== MariaDB ==== |
||
− | ownCloud 8.1.0-1 は {{ic|/dev/urandom}} にアクセスする必要があります。{{ic|php.ini}} で有効にしてください。 |
||
+ | {{Note|{{ic|/etc/mysql/my.cnf}} の {{ic|binlog_format}} を ''mixed'' に設定することが強く推奨されています [https://docs.nextcloud.com/server/11/admin_manual/configuration_database/linux_database_configuration.html#db-binlog-label]。}} |
||
+ | 以下は [[MariaDB]] のデータベースとユーザーを設定する例です: |
||
− | {{ic|php.ini}} の {{ic|open_basedir}} に {{ic|:/dev/urandom}} を追加します (末尾にスラッシュは付きません)。例: |
||
+ | {{hc|$ mysql -u root -p|2= |
||
+ | mysql> CREATE DATABASE `'''nextcloud'''` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; |
||
+ | mysql> CREATE USER `'''nextcloud'''`@'localhost' IDENTIFIED BY ''''password''''; |
||
+ | mysql> GRANT ALL PRIVILEGES ON `'''nextcloud'''`.* TO `'''nextcloud'''`@`localhost`; |
||
+ | mysql> \q |
||
+ | }} |
||
+ | ==== PostgreSQL ==== |
||
+ | 以下は [[PostgreSQL]] のデータベースとユーザーを設定する例です: |
||
+ | {{hc|1=$ sudo -u postgres createuser -h localhost -P nextcloud|2= |
||
+ | Enter password for new role: |
||
+ | Enter it again: |
||
+ | }} |
||
+ | {{bc|$ sudo -u postgres createdb -O nextcloud nextcloud}} |
||
+ | === ウェブサーバーの設定 === |
||
− | open_basedir = /srv/http/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/dev/urandom |
||
+ | {{Warning|平文の HTTP ではなく TLS/SSL (HTTPS) を使用することが推奨されます。詳しくは [[Apache#TLS/SSL]] や [[Nginx#TLS/SSL]] を参照してください。}} |
||
+ | 使用する[[ウェブサーバー]]によって、必要な設定は変わります。 |
||
− | もしくは、{{ic|/etc/httpd/conf/extra/owncloud.conf}} の {{ic|php_admin_value open_basedir}} に {{ic|:/dev/urandom}} を追加するほうが良い結果が得られるかもしれません。 |
||
+ | ==== Apache ==== |
||
− | Nginx + uwsgi_php では上記の設定は反映されません。uwsgi_php の設定ファイルに {{ic|:/dev/urandom}} を指定してください: |
||
+ | Apache の設定ファイルを設定ディレクトリにコピーしてください: |
||
+ | # cp /etc/webapps/nextcloud/apache.example.conf /etc/httpd/conf/extra/nextcloud.conf |
||
+ | 必要に応じてファイルの設定を変更してください。デフォルトでは {{ic|/nextcloud}} で {{ic|/usr/share/webapps/nextcloud}} が表示されるエイリアスが記述されています。 |
||
− | {{hc|/etc/uwsgi/owncloud.ini|<nowiki>php-set = open_basedir=%(owncloud_data_dir):/tmp/:/usr/share/pear/:/usr/share/webapps/owncloud:/etc/webapps/owncloud:/dev/urandom</nowiki>}} |
||
+ | 設定したら {{ic|/etc/httpd/conf/httpd.conf}} に以下を追加してください: |
||
− | === データベースのサポート === |
||
+ | Include conf/extra/nextcloud.conf |
||
− | 使用するデータベースバックエンドにあわせて、{{ic|/etc/php/php.ini}} の以下の拡張をアンコメントしてください: |
||
− | * [[MySQL]] の場合、{{ic|pdo_mysql.so}} をアンコメントしてください。 |
||
− | * [[PostgreSQL]] の場合、{{ic|pdo_pgsql.so}} と {{ic|pgsql.so}} をアンコメントして {{Pkg|php-pgsql}} をインストールしてください。 |
||
− | * [[Sqlite|SQLite]] の場合、{{ic|pdo_sqlite.so}} と {{ic|sqlite3.so}} をアンコメントして {{Pkg|php-sqlite}} をインストールしてください。 |
||
+ | Nextcloud がインストールされているルートディレクトリ (例: {{ic|/usr/share/webapps/nextcloud}}) にウェブサーバーのユーザー {{ic|http}} からアクセスできることを確認してください。 |
||
− | === Exif のサポート === |
||
− | [[公式リポジトリ]]から {{Pkg|exiv2}} をインストールして {{ic|php.ini}} で {{ic|exif.so}} エクステンションをアンコメントすることで exif サポートを有効化できます。 |
||
+ | その後 Apache ({{ic|httpd.service}}) を再起動してください。 |
||
− | === オールインワンの Docker を使う === |
||
+ | ===== WebDAV ===== |
||
− | ''ownCloud'' のインストールと設定を素早く安全に行う方法として [[Docker]] を使うことができます。[https://index.docker.io/search?q=ownCloud Docker のリポジトリ] には始めから ''ownCloud'' がインストールされている完全な LAMP スタックのイメージが複数存在します。''Docker'' コンテナは基本的に [[chroot]] 環境よりも安全でありオーバーヘッドも少なくなります。Docker 上の ''ownCloud'' はかなり古いマシンでもスムーズに動作するでしょう。普通に ''ownCloud'' をインストールするよりも大抵は ''Docker'' をインストールしてから ''ownCloud'' イメージをインストールする方が簡単で時間がかかりません。 |
||
+ | OwnCloud には [[WebDAV]] の実装が付いていますが、Apache の実装と衝突する可能性があります。WebDAV を有効にする場合 (デフォルトでは有効になっていません)、{{ic|/etc/httpd/conf/httpd.conf}} で {{ic|mod_dav}} と {{ic|mod_dav_fs}} モジュールを無効にしてください。詳しくは [https://forum.owncloud.org/viewtopic.php?f=17&t=7240] を参照。 |
||
+ | ==== Nginx ==== |
||
− | {{Note|Docker イメージは ownCloud の公式サポートがありません。}} |
||
+ | クラウドの設定ファイルを保存するための空ディレクトリを作成してください: |
||
+ | # mkdir /etc/nginx/conf.d/ |
||
+ | {{ic|/etc/nginx/nginx.conf}} の "http" セクションに以下の行を追加してください: |
||
− | == Apache の設定 == |
||
+ | |||
+ | server_names_hash_bucket_size 64; |
||
+ | include conf.d/*.conf; |
||
+ | [https://docs.nextcloud.com/server/11/admin_manual/installation/nginx_nextcloud_9x.html ドキュメント] に従って設定ファイル {{ic|/etc/nginx/conf.d/nextcloud.conf}} を作成してください。Arch のパッケージでは {{ic|/var/www/}} ではなく {{ic|/usr/share/webapps/}} にインストールされるため {{ic|root}} のディレクトリを変える必要があります。 |
||
− | {{Note|[[Apache HTTP Server#PHP]] に書かれているようにして PHP を有効化してください。}} |
||
+ | さらに、以下の部分を: |
||
− | Apache の設定ファイルを ownCloud の設定ディレクトリにコピーします: |
||
− | # cp /etc/webapps/owncloud/apache.example.conf /etc/httpd/conf/extra/owncloud.conf |
||
+ | upstream php-handler { |
||
− | そして {{ic|/etc/httpd/conf/httpd.conf}} の一番下で設定ファイルをインクルードします: |
||
+ | server 127.0.0.1:9000; |
||
− | Include conf/extra/owncloud.conf |
||
+ | #server unix:/var/run/php5-fpm.sock; |
||
+ | } |
||
+ | 以下のように変更してください: |
||
− | セキュリティを確保するために、[https://doc.owncloud.org/server/8.0/admin_manual/installation/installation_wizard.html#setting-strong-directory-permissions ownCloud のインストールマニュアル] に書かれているようにディレクトリのパーティションを設定してください: |
||
− | #!/bin/bash |
||
− | ocpath='/usr/share/webapps/owncloud' |
||
− | htuser='http' |
||
− | htgroup='http' |
||
− | find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640 |
||
− | find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750 |
||
− | chown -R root:${htuser} ${ocpath}/ |
||
− | chown -R ${htuser}:${htgroup} ${ocpath}/apps/ |
||
− | chown -R ${htuser}:${htgroup} ${ocpath}/config/ |
||
− | chown -R ${htuser}:${htgroup} ${ocpath}/data/ |
||
− | chown -R ${htuser}:${htgroup} ${ocpath}/themes/ |
||
− | chown root:${htuser} ${ocpath}/.htaccess |
||
− | chown root:${htuser} ${ocpath}/data/.htaccess |
||
− | chmod 0644 ${ocpath}/.htaccess |
||
− | chmod 0644 ${ocpath}/data/.htaccess |
||
+ | upstream php-handler { |
||
− | そして Apache ({{ic|httpd.service}}) を再起動します。 |
||
+ | #server 127.0.0.1:9000; |
||
+ | server unix:/run/php-fpm/php-fpm.sock; |
||
+ | } |
||
+ | [[Let’s Encrypt]] を使用してセキュアな証明書を入手することが推奨されています。[[#セキュリティの強化]]を見てください。 |
||
− | ウェブブラウザで http://localhost/owncloud を開いて下さい。ユーザーアカウントを作成してインストールウィザードに従う必要があります。 |
||
− | === |
+ | ===== PHP-FPM の設定 ===== |
+ | [[Nginx#PHP を動かす]]に書かれているようにして PHP-FPM を設定してください。 |
||
− | OwnCloud には WebDAV の実装が付いておりデフォルトで有効になっていますが、Apache の実装と衝突する可能性があります。OwnCloud は {{ic|/etc/httpd/conf/httpd.conf}} で {{ic|mod_dav}} と {{ic|mod_dav_fs}} を無効化することを [http://forum.owncloud.org/viewtopic.php?f=17&t=7240 推奨] しています。 |
||
+ | {{ic|/etc/php/php-fpm.d/www.conf}} の {{ic|1=env[PATH] = /usr/local/bin:/usr/bin:/bin}} をアンコメントしてから {{ic|php-fpm.service}} を[[再起動]]して変更を適用してください。 |
||
− | === サブディレクトリで ownCloud を動かす === |
||
+ | == 初期化 == |
||
− | デフォルトの {{ic|owncloud.conf}} を {{ic|httpd.conf}} でインクルードすることで、ownCloud は80番ポートと localhost ドメインをコントロールします。 |
||
+ | ウェブブラウザで Nextcloud をインストールした PC のアドレスを開いてください (例: https://www.examples.com/nextcloud)。指示に従って管理者アカウントを追加し先に作成したデータベースを選択します。 |
||
− | サブディレクトリで ownCloud を動作させたい場合は、{{ic|/etc/httpd/conf/extra/owncloud.conf}} を編集して include ファイルの {{ic|<nowiki><VirtualHost *:80> ... </VirtualHost></nowiki>}} の部分をコメントアウトしてください。 |
||
− | == |
+ | == セキュリティの強化 == |
+ | [https://docs.nextcloud.com/server/11/admin_manual/configuration_server/harden_server.html Nextcloud Hardening and Security] の記事に一般的なトピックの説明があります。[https://scan.nextcloud.com/ セキュリティスキャナ] も参照。 |
||
− | ownCloud の公式ドキュメントでは php-fpm で PHP を使っています。したがってそれが最もサポートされている構成になります。以下は Arch Linux で動作するように、[https://doc.owncloud.org/server/8.1/admin_manual/installation/nginx_configuration.html 推奨されるサーバー設定] から多少変更を加えています。{{pkg|php-fpm}} と SSL 証明書が必要です。 |
||
+ | === Let's Encrypt === |
||
− | {{bc|<nowiki> |
||
+ | ==== nginx ==== |
||
− | user http; |
||
+ | [https://github.com/graysky2/configs/blob/master/nginx/nextcloud-initial.conf こちらのファイル] をテンプレートとして使ってクラウド設定の {{ic|/etc/nginx/conf.d/cloud-initial.conf}} を作成してください。テンプレートファイルの "@@FQDN@@" は実際に使用する [https://en.wikipedia.org/wiki/Fully_qualified_domain_name FQDN] に置き換えてください。最初に暗号化されない設定を使うにはサーバーの証明書を生成する必要があります。[[Let’s Encrypt]] に書かれている手順に従ってサーバーの暗号化証明書を作成してください。 |
||
− | worker_processes auto; |
||
+ | 証明書を作成できたら {{ic|/etc/nginx/conf.d/cloud-initial.conf}} を新しいファイル {{ic|/etc/nginx/conf.d/cloud.conf}} に置き換えてください (it may be safely renamed so long as it does not end in ".conf" or simply deleted)。[https://github.com/graysky2/configs/blob/master/nginx/nextcloud.conf こちらのファイル] をテンプレートとして使うことができます。"@@FQDN@@" は実際に使用する [https://en.wikipedia.org/wiki/Fully_qualified_domain_name FQDN] に置き換えてください。その後 {{ic|nginx.service}} を[[起動]]・[[有効化]]してください。 |
||
− | events { |
||
− | worker_connections 1024; |
||
− | } |
||
+ | === uWSGI === |
||
− | http { |
||
− | |||
− | #sendfile on; # Appears to cause problems with webdav. |
||
− | #tcp_nopush on; |
||
+ | {{pkg|uwsgi-plugin-php}} による [[uWSGI]] アプリケーションサーバーを使うことで ownCloud を固有のプロセスで動かすことができます。システム全体の {{ic|php.ini}} を編集しなくても、インスタンスの [[PHP#設定|PHP 設定]]を定義することができるため、ウェブアプリケーションの設定を分離することが可能です。uWSGI 自体にリソースの使用を制限するための機能が豊富に含まれており、アプリケーションのセキュリティを強化したり、専用のユーザーで動くようにプロセスを分けられます。 |
||
− | server { |
||
− | listen 80; |
||
− | server_name owncloud.example.com; |
||
− | # enforce https |
||
− | return 301 https://$server_name$request_uri; |
||
− | } |
||
+ | [[#PHP-FPM の設定|PHP-FPM の設定]]と異なるところは {{ic|<nowiki>location ~ \.php(?:$|/) {}</nowiki>}} ブロックだけです: |
||
− | server { |
||
+ | {{bc|<nowiki> |
||
− | include mime.types; |
||
+ | location ~ \.php(?:$|/) { |
||
− | default_type application/octet-stream; |
||
+ | include uwsgi_params; |
||
+ | uwsgi_modifier1 14; |
||
+ | # Avoid duplicate headers confusing OC checks |
||
+ | uwsgi_hide_header X-Frame-Options; |
||
+ | uwsgi_hide_header X-XSS-Protection; |
||
+ | uwsgi_hide_header X-Content-Type-Options; |
||
+ | uwsgi_hide_header X-Robots-Tag; |
||
+ | uwsgi_pass unix:/run/uwsgi/owncloud.sock; |
||
+ | } |
||
+ | </nowiki>}} |
||
+ | それから ''uWSGI'' の設定ファイルを作成してください: |
||
− | listen 443 ssl; |
||
− | server_name owncloud.example.com; |
||
+ | {{hc|/etc/uwsgi/owncloud.ini|<nowiki> |
||
− | ssl_certificate /etc/ssl/server.crt; |
||
+ | [uwsgi] |
||
− | ssl_certificate_key /etc/ssl/server.key; |
||
+ | ; load the required plugins |
||
+ | plugins = php |
||
+ | ; force the sapi name to 'apache', this will enable the opcode cache |
||
+ | php-sapi-name = apache |
||
+ | ; set master process name and socket |
||
− | # Add headers to serve security related headers |
||
+ | ; '%n' refers to the name of this configuration file without extension |
||
− | add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;"; |
||
+ | procname-master = uwsgi %n |
||
− | add_header X-Content-Type-Options nosniff; |
||
+ | master = true |
||
− | add_header X-Frame-Options "SAMEORIGIN"; |
||
+ | socket = /run/uwsgi/%n.sock |
||
− | add_header X-XSS-Protection "1; mode=block"; |
||
− | add_header X-Robots-Tag none; |
||
+ | ; drop privileges |
||
− | # Path to the root of your installation |
||
+ | uid = http |
||
− | root /usr/share/webapps/owncloud; |
||
+ | gid = http |
||
− | # set max upload size |
||
+ | umask = 027 |
||
− | client_max_body_size 10G; |
||
− | fastcgi_buffers 64 4K; |
||
+ | ; run with at least 1 process but increase up to 4 when needed |
||
− | # Disable gzip to avoid the removal of the ETag header |
||
+ | processes = 4 |
||
− | gzip off; |
||
+ | cheaper = 1 |
||
+ | ; reload whenever this config file changes |
||
− | # Uncomment if your server is build with the ngx_pagespeed module |
||
+ | ; %p is the full path of the current config file |
||
− | # This module is currently not supported. |
||
+ | touch-reload = %p |
||
− | #pagespeed off; |
||
+ | ; disable uWSGI request logging |
||
− | rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect; |
||
+ | ;disable-logging = true |
||
− | rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect; |
||
− | rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect; |
||
+ | ; enforce a DOCUMENT_ROOT |
||
− | index index.php; |
||
+ | php-docroot = /usr/share/webapps/%n |
||
− | error_page 403 /core/templates/403.php; |
||
+ | ; limit allowed extensions |
||
− | error_page 404 /core/templates/404.php; |
||
+ | php-allowed-ext = .php |
||
+ | ; and search for index.php if required |
||
+ | php-index = index.php |
||
+ | ; set php configuration for this instance of php, no need to edit global php.ini |
||
− | location = /robots.txt { |
||
+ | php-set = date.timezone=Etc/UTC |
||
− | allow all; |
||
+ | ;php-set = open_basedir=/tmp/:/usr/share/webapps/owncloud:/etc/webapps/owncloud:/dev/urandom |
||
− | log_not_found off; |
||
+ | php-set = expose_php=false |
||
− | access_log off; |
||
+ | ; avoid security risk of leaving sessions in world-readable /tmp |
||
− | } |
||
+ | php-set = session.save_path=/usr/share/webapps/owncloud/data |
||
+ | ; port of php directives set upstream in /usr/share/webapps/owncloud/.user.ini for use with PHP-FPM |
||
− | location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README){ |
||
+ | php-set = upload_max_filesize=513M |
||
− | deny all; |
||
+ | php-set = post_max_size=513M |
||
− | } |
||
+ | php-set = memory_limit=512M |
||
+ | php-set = output_buffering=off |
||
+ | ; load all extensions only in this instance of php, no need to edit global php.ini |
||
− | location / { |
||
+ | ;; required core modules |
||
− | # The following 2 rules are only needed with webfinger |
||
+ | php-set = extension=gd.so |
||
− | rewrite ^/.well-known/host-meta /public.php?service=host-meta last; |
||
+ | php-set = extension=iconv.so |
||
− | rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last; |
||
+ | ;php-set = extension=zip.so # enabled by default in global php.ini |
||
+ | ;; database connectors |
||
− | rewrite ^/.well-known/carddav /remote.php/carddav/ redirect; |
||
+ | ;; uncomment your selected driver |
||
− | rewrite ^/.well-known/caldav /remote.php/caldav/ redirect; |
||
+ | ;php-set = extension=pdo_sqlite.so |
||
+ | ;php-set = extension=pdo_mysql.so |
||
+ | ;php-set = extension=pdo_pgsql.so |
||
+ | ;; recommended extensions |
||
− | rewrite ^(/core/doc/[^\/]+/)$ $1/index.html; |
||
+ | ;php-set = extension=curl.so # enabled by default in global php.ini |
||
+ | php-set = extension=bz2.so |
||
+ | php-set = extension=intl.so |
||
+ | php-set = extension=mcrypt.so |
||
+ | ;; required for specific apps |
||
− | try_files $uri $uri/ /index.php; |
||
+ | ;php-set = extension=ldap.so # for LDAP integration |
||
− | } |
||
+ | ;php-set = extension=ftp.so # for FTP storage / external user authentication |
||
+ | ;php-set = extension=imap.so # for external user authentication, requires php-imap |
||
+ | ;; recommended for specific apps |
||
− | location ~ \.php(?:$|/) { |
||
+ | ;php-set = extension=exif.so # for image rotation in pictures app, requires exiv2 |
||
− | fastcgi_split_path_info ^(.+\.php)(/.+)$; |
||
+ | ;php-set = extension=gmp.so # for SFTP storage |
||
− | include fastcgi_params; |
||
− | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
||
− | fastcgi_param PATH_INFO $fastcgi_path_info; |
||
− | fastcgi_param HTTPS on; |
||
− | fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice |
||
− | # Unix domain sockets are faster than TCP sockets |
||
− | fastcgi_pass unix:/run/php-fpm/php-fpm.sock; |
||
− | } |
||
+ | ;; for preview generation |
||
− | # Optional: set long EXPIRES header on static assets |
||
+ | ;; provided by packages in AUR |
||
− | location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ { |
||
+ | ; php-set = extension=imagick.so |
||
− | expires 30d; |
||
− | # Optional: Don't log access to assets |
||
− | access_log off; |
||
− | } |
||
+ | ; opcache |
||
− | } |
||
+ | php-set = zend_extension=opcache.so |
||
− | } |
||
+ | |||
+ | ; user cache |
||
+ | ; provided by php-acpu, to be enabled **either** here **or** in /etc/php/conf.d/apcu.ini |
||
+ | php-set = extension=apcu.so |
||
+ | ; per https://github.com/krakjoe/apcu/blob/simplify/INSTALL |
||
+ | php-set = apc.ttl=7200 |
||
+ | php-set = apc.enable_cli=1 |
||
+ | |||
+ | cron2 = minute=-15,unique=1 /usr/bin/php -f /usr/share/webapps/owncloud/cron.php 1>/dev/null |
||
</nowiki>}} |
</nowiki>}} |
||
+ | {{Note| |
||
− | {{pkg|php-fpm}} を http ユーザーで動作させるように設定して、上記のようにパーミッションを設定すれば、動作するはずです。ownCloud の設定の {{ic|config.example.php}} を手動でコピーするのは推奨されていません。最初の実行時に自動的に生成されます。{{ic|/usr/share/webapps/owncloud/data}} という ownCloud のデータディレクトリを作成して所有者を root:http にすることで自動設定が行われます。 |
||
+ | * 必ず uWSGI 設定ファイルでタイムゾーンを設定して使用するデータベースコネクタをアンコメントしてください。 |
||
+ | * PHP 7 から、[[PHP#設定|open_basedir]] ディレクトリは上流と同じように [https://www.archlinux.jp/news/php-70-packages-released/ デフォルトでは設定されなくなりました]。使用すると [https://github.com/owncloud/core/search?q=open_basedir&type=Issues&utf8=%E2%9C%93 一部の機能が使えなくなる] 可能性があります。 |
||
+ | * nextcloud を {{ic|/nextcloud}} サブディレクトリに配置する場合は {{ic|php-docroot = /usr/share/webapps}} を使ってください。}} |
||
+ | {{Warning|[https://uwsgi-docs.readthedocs.org/en/latest/Cron.html uWSGI cron] によって設定される [https://doc.owncloud.org/server/9.0/admin_manual/configuration_server/background_jobs_configuration.html ownCloud のバックグラウンドジョブ] は {{ic|/etc/php/php.ini}} のグローバル設定を使用します。必要なモジュールなどのパラメータが有効にならず、[https://github.com/owncloud/core/issues/12678#issuecomment-66114448 様々な問題] が発生します。{{ic|/etc/php/php.ini}} を {{ic|/etc/uwsgi/cron-php.ini}} などにコピーして必要な設定 ({{ic|/etc/uwsgi/owncloud.ini}} のパラメータ) を行い、cron で ''php'' を実行する箇所に {{ic|-c /etc/uwsgi/cron-php.ini}} オプションを追加することで問題は解決します。}} |
||
− | == Nginx + uwsgi_php の設定 == |
||
+ | ==== 有効化 ==== |
||
− | Apache を使わずに、{{pkg|uwsgi-plugin-php}} アプリケーションサーバーを使って ownCloud を固有のプロセスで動かすことができます。uWSGI 自体にリソースの使用を制限するための機能が豊富に含まれており、アプリケーションのセキュリティを強化したり、専用のユーザーで動くようにプロセスを分けられます。 |
||
+ | [[uWSGI]] には設定ファイルをインスタンスの識別子として使ってアプリケーションを起動したり有効化できる[[Systemd#ユニットを使う|テンプレートユニット]]が入っています。例えば: |
||
− | === 設定 === |
||
+ | # systemctl start uwsgi@owncloud.socket |
||
+ | 上のコマンドは {{ic|/etc/uwsgi/owncloud.ini}} 設定ファイルを参照して必要に応じて起動します。 |
||
+ | |||
+ | ブート時にデフォルトで uwsgi サービスを有効化するには、次を実行: |
||
+ | # systemctl enable uwsgi@owncloud.socket |
||
+ | {{Note|[http://0pointer.de/blog/projects/socket-activation.html systemd のソケットアクティベーション] を利用することで、インスタンスへの接続がない間は無駄にリソースを消費しないようにしています。すぐに有効化したい場合は、{{ic|.socket}} という部分を削除してサービスを起動・有効化してください。}} |
||
− | *まず最初に Nginx サーバーをセットアップしてください。詳しくは [[Nginx]] のページを参照。 |
||
− | *{{ic|/etc/nginx/nginx.conf}} ファイルの http セクションに以下の行でサーバーを設定: |
||
− | {{bc|<nowiki> |
||
− | # your nginx-server configs |
||
− | # ... |
||
+ | [[uWSGI#サービスの起動]]も参照。 |
||
− | # uncomment to run as user and group http |
||
− | #user http; |
||
+ | === ファイルシステムのパーティションの設定 === |
||
− | http { |
||
− | # more configs |
||
− | # ... |
||
− | server { |
||
− | listen 80; |
||
− | #listen 443 ssl; |
||
− | server_name localhost; |
||
+ | セキュリティを強化するために ownCloud ディレクトリのパーミッションはできるだけ制限的に設定することを推奨します。インストールを行った後、セットアップを開始する前に設定してください。HTTP ユーザーが {{ic|config/}}, {{ic|data/}}, {{ic|apps/}} ディレクトリの所有者となっていれば ownCloud を設定したりデータファイルを作成・修正・削除したり、ownCloud のウェブインターフェイスでアプリをインストールできます [https://docs.nextcloud.com/server/11/admin_manual/installation/installation_wizard.html#setting-strong-directory-permissions]。 |
||
− | #ssl_certificate cert.pem; |
||
− | #ssl_certificate_key key.pem; |
||
+ | {{Note|Nextcloud のパッケージには同じようなスクリプトである {{ic|/usr/bin/set-nc-perms}} が含まれていますが、ownCloud のパッケージには含まれていません。}} |
||
− | #ssl_session_cache shared:SSL:1m; |
||
− | #ssl_session_timeout 5m; |
||
+ | {{hc|oc-perms|2=<nowiki> |
||
− | #ssl_ciphers HIGH:!aNULL:!MD5; |
||
+ | #!/bin/bash |
||
− | #ssl_prefer_server_ciphers on; |
||
+ | ocpath='/usr/share/webapps/nextcloud' |
||
+ | htuser='http' |
||
+ | htgroup='http' |
||
+ | rootuser='root' |
||
+ | printf "Creating possible missing Directories\n" |
||
− | #this is to avoid Request Entity Too Large error |
||
+ | mkdir -p $ocpath/data |
||
− | client_max_body_size 1000M; |
||
+ | mkdir -p $ocpath/assets |
||
− | # deny access to some special files |
||
− | location ~ ^/(data|config|\.ht|db_structure\.xml|README) { |
||
− | deny all; |
||
− | } |
||
− | # pass all .php or .php/path urls to uWSGI |
||
− | location ~ ^(.+\.php)(.*)$ { |
||
− | include uwsgi_params; |
||
− | uwsgi_modifier1 14; |
||
− | #Uncomment line below if you get connection refused error. Remember to comment out line with "uwsgi_pass 127.0.0.1:3001;" below |
||
− | #uwsgi_pass unix:/run/uwsgi/owncloud.sock; |
||
− | uwsgi_pass 127.0.0.1:3001; |
||
− | } |
||
− | # everything else goes to the filesystem, |
||
− | # but / will be mapped to index.php and run through uwsgi |
||
− | location / { |
||
− | root /usr/share/webapps/owncloud; |
||
− | index index.php; |
||
− | rewrite ^/.well-known/carddav /remote.php/carddav/ redirect; |
||
− | rewrite ^/.well-known/caldav /remote.php/caldav/ redirect; |
||
− | } |
||
− | } |
||
− | } |
||
− | </nowiki>}} |
||
− | *次に [[Uwsgi|uWSGI]] の設定ファイルを作成します。{{ic|/etc/uwsgi/owncloud.ini}} を使うと良いでしょう: |
||
− | {{bc|<nowiki> |
||
− | [uwsgi] |
||
− | master = true |
||
− | socket = 127.0.0.1:3001 |
||
+ | printf "chmod Files and Directories\n" |
||
− | # Change this to where you want ownlcoud data to be stored (maybe /home/owncloud) |
||
+ | find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640 |
||
− | owncloud_data_dir = /usr/share/webapps/owncloud/data/ |
||
+ | find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750 |
||
− | chdir = %(owncloud_data_dir) |
||
+ | printf "chown Directories\n" |
||
− | plugins = php |
||
+ | chown -R ${rootuser}:${htgroup} ${ocpath}/ |
||
− | php-docroot = /usr/share/webapps/owncloud |
||
+ | chown -R ${htuser}:${htgroup} ${ocpath}/apps/ |
||
− | php-index = index.php |
||
+ | chown -R ${htuser}:${htgroup} ${ocpath}/config/ |
||
+ | chown -R ${htuser}:${htgroup} ${ocpath}/data/ |
||
+ | chown -R ${htuser}:${htgroup} ${ocpath}/themes/ |
||
+ | chown -R ${htuser}:${htgroup} ${ocpath}/assets/ |
||
+ | chmod +x ${ocpath}/occ |
||
− | # only allow these php files, I don't want to inadvertently run something else |
||
− | php-allowed-ext = /index.php |
||
− | php-allowed-ext = /public.php |
||
− | php-allowed-ext = /remote.php |
||
− | php-allowed-ext = /cron.php |
||
− | php-allowed-ext = /status.php |
||
− | php-allowed-ext = /settings/apps.php |
||
− | php-allowed-ext = /core/ajax/update.php |
||
− | php-allowed-ext = /core/ajax/share.php |
||
− | php-allowed-ext = /core/ajax/requesttoken.php |
||
− | php-allowed-ext = /core/ajax/translations.php |
||
− | php-allowed-ext = /search/ajax/search.php |
||
− | php-allowed-ext = /search/templates/part.results.php |
||
− | php-allowed-ext = /settings/admin.php |
||
− | php-allowed-ext = /settings/users.php |
||
− | php-allowed-ext = /settings/personal.php |
||
− | php-allowed-ext = /settings/help.php |
||
− | php-allowed-ext = /settings/ajax/getlog.php |
||
− | php-allowed-ext = /settings/ajax/setlanguage.php |
||
− | php-allowed-ext = /settings/ajax/setquota.php |
||
− | php-allowed-ext = /settings/ajax/userlist.php |
||
− | php-allowed-ext = /settings/ajax/createuser.php |
||
− | php-allowed-ext = /settings/ajax/removeuser.php |
||
− | php-allowed-ext = /settings/ajax/enableapp.php |
||
− | php-allowed-ext = /core/ajax/appconfig.php |
||
− | php-allowed-ext = /settings/ajax/setloglevel.php |
||
− | php-allowed-ext = /ocs/v1.php |
||
+ | printf "chmod/chown .htaccess\n" |
||
− | # set php configuration for this instance of php, no need to edit global php.ini |
||
+ | if [ -f ${ocpath}/.htaccess ] |
||
− | php-set = date.timezone=Etc/UTC |
||
+ | then |
||
− | php-set = open_basedir=%(owncloud_data_dir):/tmp/:/usr/share/pear/:/usr/share/webapps/owncloud:/etc/webapps/owncloud:/dev/urandom |
||
+ | chmod 0644 ${ocpath}/.htaccess |
||
− | php-set = session.save_path=/tmp |
||
+ | chown ${rootuser}:${htgroup} ${ocpath}/.htaccess |
||
− | php-set = post_max_size=1000M |
||
+ | fi |
||
− | php-set = upload_max_filesize=1000M |
||
+ | if [ -f ${ocpath}/data/.htaccess ] |
||
− | php-set = always_populate_raw_post_data=-1 |
||
+ | then |
||
+ | chmod 0644 ${ocpath}/data/.htaccess |
||
+ | chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess |
||
+ | fi |
||
+ | </nowiki>}} |
||
+ | 標準的なインストール場所からファイルパスをカスタマイズしている場合、上記のスクリプトも修正する必要があります。 |
||
− | # load all extensions only in this instance of php, no need to edit global php.ini |
||
− | php-set = extension=bz2.so |
||
− | php-set = extension=curl.so |
||
− | php-set = extension=intl.so |
||
− | php-set = extension=pdo_sqlite.so |
||
− | php-set = extension=exif.so |
||
− | php-set = extension=gd.so |
||
− | php-set = extension=imagick.so |
||
− | php-set = extension=gmp.so |
||
− | php-set = extension=iconv.so |
||
− | php-set = extension=mcrypt.so |
||
− | php-set = extension=sockets.so |
||
− | php-set = extension=sqlite3.so |
||
− | php-set = extension=xmlrpc.so |
||
− | php-set = extension=xsl.so |
||
− | php-set = extension=zip.so |
||
− | # uncomment following line to use mysql-backend |
||
− | #php-set = extension=pdo_mysql.so |
||
+ | === fail2ban によるハッキングからの防護 === |
||
− | processes = 10 |
||
+ | [[fail2ban]] のセットアップが強く推奨されています。インストールしたら、以下のファイルを作成してください: |
||
− | cheaper = 2 |
||
− | cron = -3 -1 -1 -1 -1 /usr/bin/php -f /usr/share/webapps/owncloud/cron.php 1>/dev/null |
||
+ | {{hc|/etc/fail2ban/filter.d/owncloud.conf|<nowiki> |
||
− | # Uncomment line below and replace http with a specific user/group name which you want uwsgi to run with. |
||
+ | [Definition] |
||
− | #uid = http |
||
+ | failregex={"reqId":".*","remoteAddr":".*","app":"core","message":"Login failed: '.*' \(Remote IP: '<HOST>'\)","level":2,"time":".*"} |
||
− | #gid = http |
||
+ | |||
+ | ignoreregex = |
||
</nowiki>}} |
</nowiki>}} |
||
+ | {{hc|/etc/fail2ban/jail.local|<nowiki> |
||
− | === 有効化 === |
||
+ | [owncloud] |
||
+ | enabled = true |
||
+ | filter = owncloud |
||
+ | port = http,https |
||
+ | logpath = /usr/share/webapps/owncloud/data/owncloud.log |
||
+ | # optionally whitelist internal LAN IP addresses |
||
+ | ignoreip = 192.168.1.1/24 |
||
+ | </nowiki>}} |
||
+ | 設定後 {{ic|fail2ban}} サービスを[[systemd#ユニットを使う|再起動]]してください。以下を実行することで設定をテストできます: |
||
− | [[Uwsgi|uWSGI]] には設定ファイルをインスタンスの識別子として使ってアプリケーションを起動したり有効化できる[[Systemd#ユニットを使う|テンプレートユニット]]が入っています。例えば: |
||
+ | # fail2ban-regex /usr/share/webapps/owncloud/data/owncloud.log /etc/fail2ban/filter.d/owncloud.conf -v |
||
− | # systemctl start uwsgi@owncloud.socket |
||
− | 上のコマンドは {{ic|/etc/uwsgi/owncloud.ini}} 設定ファイルを参照して必要に応じて起動します。 |
||
− | |||
− | ブート時にデフォルトで uwsgi サービスを有効化するには、次を実行: |
||
− | # systemctl enable uwsgi@owncloud.socket |
||
+ | == Arch パッケージのアップデートに伴うメンテナンス == |
||
− | {{Note|[http://0pointer.de/blog/projects/socket-activation.html systemd のソケットアクティベーション] を利用することで、インスタンスへの接続がない間は無駄にリソースを消費しないようにしています。すぐに有効化したい場合は、{{ic|.socket}} という部分を削除してサービスを起動・有効化してください。}} |
||
+ | |||
+ | Arch の nextcloud パッケージを pacman で更新した場合、ウェブインターフェイスから手動で関連ファイルのアップデートを実行する必要があります。もしくは、シェルから ''http'' ユーザーとして {{ic|/usr/share/webapps/nextcloud/occ upgrade}} を実行することでもアップデートできます: |
||
+ | # sudo -u http /usr/share/webapps/nextcloud/occ upgrade |
||
+ | {{Note|上記のアップデートを行わないとモバイルアプリから接続できなくなります。}} |
||
− | [[Uwsgi#サービスの起動]]も参照。 |
||
== 同期 == |
== 同期 == |
||
377行目: | 346行目: | ||
=== デスクトップ === |
=== デスクトップ === |
||
+ | 公式クライアントは {{Pkg|owncloud-client}} または {{aur|nextcloud-client}} パッケージでインストールできます。 |
||
− | 公式クライアントは {{Pkg|owncloud-client}} パッケージでインストールできます。[[AUR]] には様々なバージョンが存在します: {{AUR|owncloud-client-beta}}{{Broken package link|{{aur-mirror|owncloud-client-beta}}}}, {{AUR|owncloud-client-git}} and {{AUR|owncloud-client-qt5}}{{Broken package link|{{aur-mirror|owncloud-client-qt5}}}}。使用方法はドキュメントの [http://doc.owncloud.org/server/7.0/user_manual/files/sync.html こちらのページ] に書かれています。 |
||
==== カレンダー ==== |
==== カレンダー ==== |
||
389行目: | 358行目: | ||
<nowiki>https://ADDRESS/remote.php/caldav</nowiki> |
<nowiki>https://ADDRESS/remote.php/caldav</nowiki> |
||
− | 詳しくは [http://doc.owncloud.org/server/7.0/user_manual/pim/calendar.html#synchronizing-calendars-using-caldav 公式ドキュメント] を見て |
+ | 詳しくは [http://doc.owncloud.org/server/7.0/user_manual/pim/calendar.html#synchronizing-calendars-using-caldav 公式ドキュメント] を見てください。 |
==== 連絡先 ==== |
==== 連絡先 ==== |
||
403行目: | 372行目: | ||
ownCloud をマウントするには、次のコマンドを使います: |
ownCloud をマウントするには、次のコマンドを使います: |
||
− | # mount https://own.example.com/remote.php/webdav /path/to/mount |
+ | # mount -t davfs https://own.example.com/remote.php/webdav /path/to/mount |
{{ic|/etc/fstab}} にエントリを作成することもできます: |
{{ic|/etc/fstab}} にエントリを作成することもできます: |
||
+ | {{hc|/etc/fstab|https://own.example.com/remote.php/webdav /path/to/mount davfs rw,user,noauto 0 0}} |
||
− | {{hc|/etc/fstab| |
||
+ | |||
− | https://own.example.com/remote.php/webdav /path/to/mount davfs rw,user,noauto 0 0 |
||
+ | {{Tip|自動でマウントしたい場合、[[Davfs#通常ユーザーでマウント]]で説明されているようにファイルにユーザー名 (と必要であればパスワード) を保存できます。}} |
||
− | }} |
||
+ | |||
− | {{Tip|自動でマウントできるように [[Davfs#通常ユーザーでマウント]] で説明されているようにファイルにユーザー名 (と必要であればパスワード) を保存できます。}} |
||
− | {{Note|ディレクトリは作成・コピーできるのに、ファイルの作成やコピーができない場合、[[Davfs#ファイルの作成やコピーができない]] |
+ | {{Note|ディレクトリは作成・コピーできるのに、ファイルの作成やコピーができない場合、[[Davfs#ファイルの作成やコピーができない]]を見てください。}} |
=== Android === |
=== Android === |
||
426行目: | 395行目: | ||
* 4.0 以下のバージョンの Android を使っていて、フリーのソフトウェアを使いたい場合、カレンダーと連絡先の同期には [https://f-droid.org/repository/browse/?fdfilter=caldav&fdid=com.morphoss.acal aCal] を、カレンダーだけの同期には CalDAV Sync Adapter ([https://f-droid.org/repository/browse/?fdfilter=caldav&fdid=org.gege.caldavsyncadapter F-Droid]) を試して下さい。フリーでないソフトウェアを使う気があるのであれば、[http://dmfs.org/ CardDAV-Sync と CalDAV-Sync] の使用が [http://doc.owncloud.org/server/7.0/user_manual/pim/contacts.html#synchronizing-with-android 推奨] されています。 |
* 4.0 以下のバージョンの Android を使っていて、フリーのソフトウェアを使いたい場合、カレンダーと連絡先の同期には [https://f-droid.org/repository/browse/?fdfilter=caldav&fdid=com.morphoss.acal aCal] を、カレンダーだけの同期には CalDAV Sync Adapter ([https://f-droid.org/repository/browse/?fdfilter=caldav&fdid=org.gege.caldavsyncadapter F-Droid]) を試して下さい。フリーでないソフトウェアを使う気があるのであれば、[http://dmfs.org/ CardDAV-Sync と CalDAV-Sync] の使用が [http://doc.owncloud.org/server/7.0/user_manual/pim/contacts.html#synchronizing-with-android 推奨] されています。 |
||
− | === |
+ | === SABnzbd === |
+ | [[SABnzbd]] を使う場合、{{ic|sabnzbd.ini}} ファイルに以下を設定すると良いでしょう: |
||
− | WebDAV は大きなファイルを扱うのには向いていません、CPU とメモリを食いつぶしてしまいます。 |
||
+ | folder_rename 0 |
||
+ | というのは ownCloud はアップロードされたファイルを速攻でスキャンするからです。展開された接頭辞などを SABnzbd が削除することを予防します。 |
||
+ | == ヒントとテクニック == |
||
− | 現在のバージョンでは、ownCloud に大きなデータをコピーする良い方法はないように思われます。 |
||
+ | === サブディレクトリで ownCloud を実行 === |
||
− | 対処法: |
||
+ | {{ic|httpd.conf}} から読み込まれるデフォルトの {{ic|owncloud.conf}} では、ownCloud はポート 80 と localhost ドメインを使用します。 |
||
− | 大きなファイルをあなたの ownCloud に直接コピーし、データベースを完全リスキャンします (例えば [http://apps.owncloud.com/content/show.php?content=151948&forumpage=0&PHPSESSID=37b915160effcc0f37cc761ad2ab88be Re-scan filesystem] アドオンを使うことができます)。 |
||
+ | サブディレクトリで ownCloud を使いたい場合、{{ic|/etc/httpd/conf/extra/owncloud.conf}} を編集して {{ic|<nowiki><VirtualHost *:80> ... </VirtualHost></nowiki>}} という部分をコメントアウトしてください。 |
||
− | ですが、この方法は将来 ownCloud が計画している end-to-end 暗号化が実装された時に使えなくなるかもしれないので、注意してください。 |
||
+ | uwsgi で owncloud を使用する場合、以下の nginx 設定が使えます: |
||
− | == 重要なノート == |
||
+ | {{hc|head=/etc/nginx/conf.d/owncloud.conf|output=<nowiki> |
||
+ | location = /.well-known/carddav { |
||
+ | return 301 $scheme://$host/owncloud/remote.php/dav; |
||
+ | } |
||
+ | location = /.well-known/caldav { |
||
− | * owncloud.example.xxx のようなサブドメインを使う場合、証明書でカバーされているか確認してください。そうでなければ、ownCloud クライアントや wevdav からの接続は失敗するかもしれません。 |
||
+ | return 301 $scheme://$host/owncloud/remote.php/dav; |
||
+ | } |
||
+ | location /.well-known/acme-challenge { } |
||
− | * ownCloud の [http://owncloud.org/sync-clients/ sync-clients] を使うことを計画しているなら、[[Network Time Protocol daemon|ntpd]] をインストールして ownCloud サーバーで実行してください。ntpd が実行されてないと、sync-client は失敗します。 |
||
+ | location ^~ /owncloud { |
||
− | * 接続には [[LAMP#SSL|SSL 暗号化]]を追加してください! |
||
− | (上記のように SSL 暗号化を追加する場合、{{ic|/etc/httpd/conf/extra/httpd-ssl.conf}} を編集して {{ic|DocumentRoot "/srv/http"}} を {{ic|DocumentRoot "/usr/share/webapps/owncloud"}} に変更してください。) |
||
+ | root /usr/share/webapps; |
||
− | * ownCloud のアプリは他にも [http://apps.owncloud.com/ ここ] で探すことができます。 |
||
+ | # set max upload size |
||
− | * 新しいアプリケーションをインストールするには、アプリストアから zip をダウンロードして、それを {{ic|/srv/http/owncloud/apps/}} に展開します。その後、httpd を再起動してください: |
||
+ | client_max_body_size 512M; |
||
+ | fastcgi_buffers 64 4K; |
||
+ | # Disable gzip to avoid the removal of the ETag header |
||
− | # systemctl restart httpd |
||
+ | gzip off; |
||
+ | # Uncomment if your server is build with the ngx_pagespeed module |
||
− | サーバーにログインしてアプリセクションを開けば新しいアプリが追加されているはずです。 |
||
+ | # This module is currently not supported. |
||
+ | #pagespeed off; |
||
+ | location /owncloud { |
||
− | * HTTP のベーシック認証で ownCloud へのアクセスを保護するときは、"status.php" ファイルは認証から外して誰でもアクセスできるようにしてください [https://github.com/owncloud/mirall/issues/734]。 |
||
+ | rewrite ^ /owncloud/index.php$uri; |
||
+ | } |
||
+ | location ~ ^/owncloud/(?:build|tests|config|lib|3rdparty|templates|data)/ { |
||
− | === SABnzbd === |
||
+ | deny all; |
||
+ | } |
||
+ | location ~ ^/owncloud/(?:\.|autotest|occ|issue|indie|db_|console) { |
||
− | [[en2:SABnzbd|SABnzbd]] を使う場合、{{ic|sabnzbd.ini}} ファイルに以下を設定すると良いでしょう: |
||
+ | deny all; |
||
− | folder_rename 0 |
||
+ | } |
||
− | というのは ownCloud はアップロードされたファイルを速攻でスキャンするからです。展開された接頭辞などを SABnzbd が削除することを予防します。 |
||
+ | |||
+ | location ~ ^/owncloud/(?:updater|ocs-provider)(?:$|/) { |
||
+ | try_files $uri/ =404; |
||
+ | index index.php; |
||
+ | } |
||
+ | |||
+ | location ~ ^/owncloud/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) { |
||
+ | include uwsgi_params; |
||
+ | uwsgi_modifier1 14; |
||
+ | # Avoid duplicate headers confusing OC checks |
||
+ | uwsgi_hide_header X-Frame-Options; |
||
+ | uwsgi_hide_header X-XSS-Protection; |
||
+ | uwsgi_hide_header X-Content-Type-Options; |
||
+ | uwsgi_hide_header X-Robots-Tag; |
||
+ | uwsgi_pass unix:/run/uwsgi/owncloud.sock; |
||
+ | } |
||
+ | |||
+ | # Adding the cache control header for js and css files |
||
+ | # Make sure it is BELOW the PHP block |
||
+ | location ~* \.(?:css|js) { |
||
+ | try_files $uri /owncloud/index.php$uri$is_args$args; |
||
+ | add_header Cache-Control "public, max-age=7200"; |
||
+ | # Add headers to serve security related headers (It is intended |
||
+ | # to have those duplicated to the ones above) |
||
+ | # Before enabling Strict-Transport-Security headers please read |
||
+ | # into this topic first. |
||
+ | # add_header Strict-Transport-Security "max-age=15768000; |
||
+ | # includeSubDomains; preload;"; |
||
+ | add_header X-Content-Type-Options nosniff; |
||
+ | add_header X-Frame-Options "SAMEORIGIN"; |
||
+ | add_header X-XSS-Protection "1; mode=block"; |
||
+ | add_header X-Robots-Tag none; |
||
+ | add_header X-Download-Options noopen; |
||
+ | add_header X-Permitted-Cross-Domain-Policies none; |
||
+ | # Optional: Don't log access to assets |
||
+ | access_log off; |
||
+ | } |
||
+ | |||
+ | location ~* \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg) { |
||
+ | try_files $uri /owncloud/index.php$uri$is_args$args; |
||
+ | # Optional: Don't log access to other assets |
||
+ | access_log off; |
||
+ | } |
||
+ | } |
||
+ | </nowiki>}} |
||
+ | |||
+ | === Docker === |
||
+ | [[Docker]] の [https://hub.docker.com/_/owncloud/ ownCloud] あるいは [https://github.com/nextcloud/docker Nextcloud] リポジトリを見てください。 |
||
+ | |||
+ | === ファイルマネージャからアップロード・共有 === |
||
+ | [https://github.com/schiesbn/shareLinkCreator shareLinkCreator] はサポートされているファイルマネージャから ownCloud にファイルをアップロードする機能を提供します。アップロードしたファイルのリンクをメールなどで配ることが可能です。 |
||
+ | |||
+ | === AJAX から Cron に切り替える === |
||
+ | |||
+ | Nextcloud では定期的に実行する必要があるタスクが存在しますが、デフォルトでは AJAX を使って実行されます。AJAX は信頼性に欠けるため [[Cron]] や [[systemd/タイマー]]を使うことを推奨します。 |
||
+ | |||
+ | {{hc|/etc/systemd/system/nextcloud-cron.timer|<nowiki> |
||
+ | [Unit] |
||
+ | Description=Runs Nextcloud tasks regularly |
||
+ | |||
+ | [Timer] |
||
+ | OnBootSec=10min |
||
+ | OnUnitActiveSec=15min |
||
+ | |||
+ | [Install] |
||
+ | WantedBy=timers.target</nowiki>}} |
||
+ | |||
+ | {{hc|/etc/systemd/system/nextcloud-cron.service|<nowiki> |
||
+ | [Unit] |
||
+ | Description=Nextcloud scheduled tasks |
||
+ | |||
+ | [Service] |
||
+ | Type=oneshot |
||
+ | User=http |
||
+ | Group=http |
||
+ | ExecStart=/usr/bin/php -f /usr/share/webapps/nextcloud/cron.php</nowiki>}} |
||
+ | |||
+ | もしくは以下の cron ジョブを設定: |
||
+ | */15 * * * * php -f /usr/share/webapps/nextcloud/cron.php |
||
+ | |||
+ | === Collabora Online Office の統合 === |
||
+ | {{AUR|nextcloud-app-collabora-online}} をインストールしてウェブサーバーの Nextcloud の設定を編集します。[[Nginx]] の場合: |
||
+ | |||
+ | # static files |
||
+ | location ^~ /loleaflet { |
||
+ | proxy_pass https://localhost:9980; |
||
+ | proxy_set_header Host $http_host; |
||
+ | } |
||
+ | # WOPI discovery URL |
||
+ | location ^~ /hosting/discovery { |
||
+ | proxy_pass https://localhost:9980; |
||
+ | proxy_set_header Host $http_host; |
||
+ | } |
||
+ | # websockets, download, presentation and image upload |
||
+ | location ^~ /lool { |
||
+ | proxy_pass https://localhost:9980; |
||
+ | proxy_set_header Upgrade $http_upgrade; |
||
+ | proxy_set_header Connection "upgrade"; |
||
+ | proxy_set_header Host $http_host; |
||
+ | } |
||
+ | |||
+ | [[Apache]] の場合は [https://nextcloud.com/collaboraonline/ こちら] を見てください。docker デーモンを使っている場合、Collabora Online の最新の docker イメージを pull できます。2番目のコマンドのドメイン名はあなたの Nextcloud サーバーのドメイン名に置き換えてください: |
||
+ | docker pull collabora/code |
||
+ | docker run -t -d -p 127.0.0.1:9980:9980 -e 'domain=localhost' --net host --restart always --cap-add MKNOD collabora/code |
||
+ | docker イメージを更新する際は同じコマンドを実行します。ただし旧イメージの実行中プロセスを全て終了してください: |
||
+ | docker ps |
||
+ | docker stop CONTAINER_ID |
||
+ | docker rm CONTAINER_ID |
||
+ | これで Nextcloud インスタンスで Collabora Online アプリを有効にできます。最後に管理者の設定で Collabora Online アプリに関する設定を行ってください。 |
||
== トラブルシューティング == |
== トラブルシューティング == |
||
491行目: | 585行目: | ||
=== Android デバイスの自己署名証明書 === |
=== Android デバイスの自己署名証明書 === |
||
+ | [[LAMP#TLS/SSL]] に書かれているように SSL のセットアップをした場合、古いバージョンの DAVdroid では証明書が信頼できないとして接続が拒否されます。以下のようにサーバーに証明書を作成できます: |
||
− | Once you have followed the setup for SSL, as on [https://wiki.archlinux.org/index.php/LAMP#TLS.2FSSL LAMP] for example, early versions of DAVdroid will reject the connection because the certificate is not trusted. A certificate can be made as follows on your server: |
||
− | + | # openssl x509 -req -days 365 -in /etc/httpd/conf/server.csr -signkey /etc/httpd/conf/server.key -extfile android.txt -out CA.crt |
|
− | + | # openssl x509 -inform PEM -outform DER -in CA.crt -out CA.der.crt |
|
− | + | {{ic|android.txt}} ファイルに以下を記述してください: |
|
− | + | basicConstraints=CA:true |
|
− | + | そして Android 端末に {{ic|CA.der.crt}} をインポートしてください: |
|
+ | Android 端末の SD カードに {{ic|CA.der.crt}} ファイルを保存してください (メールの添付ファイルなどを使って保存してください)。ファイルはルートディレクトリに配置してください。そして ''Settings > Security > Credential storage'' から ''Install from device storage'' を選択します。{{ic|.crt}} ファイルが検出されて、証明書の名前の入力が求められます。証明書をインポートしたら、''Settings > Security > Credential storage > Trusted credentials > User'' から確認できるはずです。 |
||
− | Put the {{ic|CA.der.crt}} file onto the sdcard of your Android device (usually to the internal one, e.g. save from a mail attachment). It should be in the root directory. Go to ''Settings > Security > Credential storage'' and select ''Install from device storage''. |
||
− | The {{ic|.crt}} file will be detected and you will be prompted to enter a certificate name. After importing the certificate, you will find it in ''Settings > Security > Credential storage > Trusted credentials > User''. |
||
ソース: [http://www.leftbrainthings.com/2013/10/13/creating-and-importing-self-signed-certificate-to-android-device/] |
ソース: [http://www.leftbrainthings.com/2013/10/13/creating-and-importing-self-signed-certificate-to-android-device/] |
||
+ | [https://play.google.com/store/apps/details?id=at.bitfire.cadroid CAdroid] を使ってサーバーから直接証明書をインポートする方法もあります。 |
||
− | === Cannot write into config directory! === |
||
+ | === 設定ディレクトリに書き込みができない === |
||
− | Check your httpd configuration file (like {{ic|owncloud.conf}}). Add your configuration directory ({{ic|/etc/webapps}} by default) to |
||
+ | |||
+ | httpd の設定ファイル ({{ic|owncloud.conf}} など) を確認してください。以下の文字列に設定ディレクトリ (デフォルトでは {{ic|/etc/webapps}}) を追加してください: |
||
php_admin_value open_basedir "/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/path/to/dir/" |
php_admin_value open_basedir "/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/path/to/dir/" |
||
+ | 変更を適用するには httpd あるいは php-fpm サービスを再起動します。 |
||
− | Restart the httpd or php-fpm service to activate the change. |
||
− | === |
+ | === データディレクトリを作成できない (/path/to/dir) === |
+ | httpd の設定ファイル ({{ic|owncloud.conf}} など) を確認してください。以下の文字列にデータディレクトリを追加してください: |
||
− | Check your httpd configuration file (like {{ic|owncloud.conf}}). Add your data directory to |
||
php_admin_value open_basedir "/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/path/to/dir/" |
php_admin_value open_basedir "/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/path/to/dir/" |
||
+ | 変更を適用するには httpd あるいは php-fpm サービスを再起動します。 |
||
− | Restart the httpd or php-fpm service to activate the change. |
||
+ | |||
+ | また PHP 7 はデフォルトでは open_basedir を使用しないため、必要なデータディレクトリの所有者・所有ユーザーを {{ic|root:http}} にしてパーミッションを 770 に変更することでも解決できます (http はウェブサーバーを実行するユーザーのグループに置き換えてください)。 |
||
=== CSync failed to find a specific file. === |
=== CSync failed to find a specific file. === |
||
+ | おそらく証明書に問題があります。証明書を再度作成して、名前を空にしないようにしてください。そうしないとエラーがまた発生します。 |
||
− | This is most likely a certificate issue. Recreate it, and do not leave the common name empty or you will see the error again. |
||
# openssl req -new -x509 -nodes -newkey rsa:4096 -keyout server.key -out server.crt |
# openssl req -new -x509 -nodes -newkey rsa:4096 -keyout server.key -out server.crt |
||
531行目: | 628行目: | ||
=== ログイン後に白いページが表示される === |
=== ログイン後に白いページが表示される === |
||
− | おそらく新しくインストールしたアプリが原因です。修正するには、[ |
+ | おそらく新しくインストールしたアプリが原因です。修正するには、[https://doc.owncloud.org/server/8.2/admin_manual/configuration_server/occ_command.html こちら] に書かれているように occ コマンドを使用します。アプリを全て確認するには: |
+ | # sudo -u http php /usr/share/webapps/owncloud/occ app:list |
||
+ | 問題のアプリを無効化するには (ownCloud を標準のディレクトリにインストールした場合): |
||
+ | # sudo -u http php /usr/share/webapps/owncloud/occ app:disable <nameOfExtension> |
||
+ | |||
+ | もしくは [[phpMyAdmin]] を使って {{ic|oc_appconfig}} テーブルを編集するか (運が良いことにテーブルに edit オプションがある場合) mysql で手動で修正してください: |
||
− | mysql -u root -p owncloud |
+ | $ mysql -u root -p owncloud |
− | MariaDB [owncloud]> '''delete from''' oc_appconfig '''where''' appid='<nameOfExtension>' '''and''' configkey='enabled' '''and''' configvalue='yes' |
+ | MariaDB [owncloud]> '''delete from''' oc_appconfig '''where''' appid='<nameOfExtension>' '''and''' configkey='enabled' '''and''' configvalue='yes'; |
MariaDB [owncloud]> '''insert into''' oc_appconfig (appid,configkey,configvalue) '''values''' ('<nameOfExtension>','enabled','no'); |
MariaDB [owncloud]> '''insert into''' oc_appconfig (appid,configkey,configvalue) '''values''' ('<nameOfExtension>','enabled','no'); |
||
541行目: | 643行目: | ||
=== GUI の同期クライアントで接続できない === |
=== GUI の同期クライアントで接続できない === |
||
− | HTTP のベーシック認証を使っている場合、 |
+ | HTTP のベーシック認証を使っている場合、{{ic|status.php}} が対象から外れていることを確認してください。このファイルは誰からでもアクセスできるようにしておく必要があります [https://github.com/owncloud/mirall/issues/734]。 |
+ | === ファイルをアップロードすると 'Integrity constraint violation...' エラーが表示される === |
||
− | === Server waits forever after creating admin account, before giving a 503 error === |
||
+ | ownCloud の同期クライアントで以下のエラーが表示されることがあります: |
||
− | If the server waits forever but the database is working, try installing all of the apps available in the ArchLinux repos. If you don't have any apps installed, it can cause issues. |
||
+ | SQLSTATE[23000]: Integrity constraint violation: ... Duplicate entry '...' for key 'fs_storage_path_hash')... |
||
− | === Some files upload, but give an error 'Integrity constraint violation...' === |
||
+ | File Locking アプリの問題が原因です。ウェブーサーバーの設定の衝突が発生しているのに対処できていません。エラーが発生しない [https://doc.owncloud.org/server/8.1/admin_manual/configuration_files/files_locking_transactional.html Transactional File Locking] が存在しますが、Redis の php キャッシュを使う必要があります。{{Pkg|redis}} と {{AUR|php-redis}} をインストールして、現在使っている php のキャッシュをコメントアウトして、{{ic|/etc/php/conf.d/redis.ini}} から {{ic|1=extension=redis.so}} をアンコメントしてください。そして {{ic|config.php}} に以下の変更を加えます: |
||
− | You may see the following error in the ownCloud sync client: |
||
+ | 'memcache.local' => '\OC\Memcache\Redis', |
||
− | SQLSTATE[23000]: Integrity constraint violation: ... Duplicate entry '...' for key 'fs_storage_path_hash')... |
||
+ | 'filelocking.enabled' => 'true', |
||
+ | 'memcache.locking' => '\OC\Memcache\Redis', |
||
+ | 'redis' => array( |
||
+ | 'host' => 'localhost', |
||
+ | 'port' => 6379, |
||
+ | 'timeout' => 0.0, |
||
+ | ), |
||
+ | 設定したら Redis を再起動: |
||
− | This is caused by an issue with the File Locking app, which is often not sufficient to keep conflicts from occurring on some webserver configurations. A more complete [https://doc.owncloud.org/server/8.1/admin_manual/configuration_files/files_locking_transactional.html Transactional File Locking] is available that rids these errors, but you must be using the Redis php-caching method. Install {{Pkg|redis}} and {{AUR|php-redis}}, comment out your current php-cache mechanism, and then in {{ic|/etc/php/conf.d/redis.ini}} uncomment {{ic|1=extension=redis.so}}. Then in {{ic|config.php}} make the following changes: |
||
+ | # systemctl enable redis.service |
||
− | 'memcache.local' => '\OC\Memcache\Redis', |
||
+ | # systemctl start redis.service |
||
− | 'filelocking.enabled' => 'true', |
||
− | 'memcache.locking' => '\OC\Memcache\Redis', |
||
− | 'redis' => array( |
||
− | 'host' => 'localhost', |
||
− | 'port' => 6379, |
||
− | 'timeout' => 0.0, |
||
− | ), |
||
+ | 最後に、File Locking アプリを無効化して、Transational File Locking を使うようにしてください。 |
||
− | and start Redis: |
||
+ | 管理者ページのサーバーステータスに 'Transactional File Locking Enabled' が表示され、同期の問題が消えるはずです。 |
||
− | systemctl enable redis.service |
||
− | systemctl start redis.service |
||
− | |||
− | Finally, disable the File Locking App, as the Transational File Locking will take care of it (and would conflict). |
||
− | |||
− | If everything is working, you should see 'Transactional File Locking Enabled' under Server Status on the Admin page, and syncs should no longer cause issues. |
||
=== "Cannot write into apps directory" === |
=== "Cannot write into apps directory" === |
||
− | + | [https://doc.owncloud.org/server/latest/admin_manual/installation/apps_management_installation.html 公式の管理者マニュアル] に書かれているように、http ユーザーからアプリディレクトリに書き込みができるようにするか、{{ic|appstoreenabled}} を {{ic|false}} に設定する必要があります。 |
|
− | |||
− | ''Also'', not mentioned there, the directory needs to be in the {{ic|open_basedir}} line in {{ic|/etc/php/php.ini}}. |
||
+ | また、ドキュメントには書かれていませんが、{{ic|/etc/php/php.ini}} の {{ic|open_basedir}} 行にディレクトリを指定してください。 |
||
− | {{Accuracy|Does not seem to work with 8.0.2}} |
||
− | + | きれいな解決方法としてパッケージによってインストールされた {{ic|/usr/share/webapps/owncloud/apps}} ディレクトリの所有者は root にしたまま、ユーザーがインストールしたアプリは http が所有者となる {{ic|/var/www/owncloud/apps}} などに入れる方法があります。それから {{ic|appstoreenabled}} を {{ic|true}} に設定してアプリのパッケージをアップグレードすれば上手く動作するはずです。{{ic|/etc/webapps/owncloud/config/config.php}} の該当する行: |
|
{{bc|<nowiki> |
{{bc|<nowiki> |
||
601行目: | 697行目: | ||
</nowiki>}} |
</nowiki>}} |
||
− | + | {{ic|/etc/php/php.ini}} の {{ic|open_basedir}} 行の例: |
|
open_basedir = /srv/http/:/usr/share/webapps/:/var/www/owncloud/apps/ |
open_basedir = /srv/http/:/usr/share/webapps/:/var/www/owncloud/apps/ |
||
+ | ディレクトリのパーミッション: |
||
− | Directory permissions: |
||
{{hc|$ ls -ld /usr/share/webapps/owncloud/apps /var/www/owncloud/apps/| |
{{hc|$ ls -ld /usr/share/webapps/owncloud/apps /var/www/owncloud/apps/| |
||
− | + | <nowiki>drwxr-xr-x 26 root root 4096 des. 14 20:48 /usr/share/webapps/owncloud/apps |
|
− | + | drwxr-xr-x 2 http http 48 jan. 20 20:01 /var/www/owncloud/apps/</nowiki>}} |
|
+ | === nginx.conf に推奨設定を記述したのにセキュリティの警告が表示される === |
||
− | === Security warnings even though the recommended settings have been included in nginx.conf === |
||
− | + | 管理者マニュアルにしたがって {{ic|Strict-Transport-Security}}, {{ic|X-Content-Type-Options}}, {{ic|X-Frame-Options}}, {{ic|X-XSS-Protection}}, {{ic|X-Robots-Tag}} を設定しても管理者ページの上部に警告が表示されることがあります。 |
|
+ | 考えられる原因として ownCloud 自身が設定を行っていて、uWSGI によって nginx に設定が重複して追加されてしまっている可能性があります: |
||
− | A possible cause could be that because owncloud sets those settings, uwsgi passed them along and nginx added them again: |
||
{{hc|$ curl -I https://domain.tld| |
{{hc|$ curl -I https://domain.tld| |
||
<nowiki>... |
<nowiki>... |
||
628行目: | 724行目: | ||
X-Robots-Tag: none</nowiki>}} |
X-Robots-Tag: none</nowiki>}} |
||
− | + | fast_cgi のサンプル設定には重複を避けるためのパラメータが存在しますが ({{ic|fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice}})、uwsgi と nginx を使用する場合、{{ic|nginx.conf}} の uwsgi の部分に以下の修正を加えることで解決します: |
|
{{hc| /etc/nginx/nginx.conf| |
{{hc| /etc/nginx/nginx.conf| |
||
647行目: | 743行目: | ||
} |
} |
||
...</nowiki>}} |
...</nowiki>}} |
||
+ | |||
+ | === "Reading from keychain failed with error: 'No keychain service available'" === |
||
+ | Gnome の場合、{{Pkg|libgnome-keyring}} と {{Pkg|gnome-keyring}} パッケージをインストールすることで解決します。KDE の場合、{{Pkg|libgnome-keyring}} と {{Pkg|qtkeychain}} パッケージをインストールしてください。 |
||
== 参照 == |
== 参照 == |
||
* [http://owncloud.org/ ownCloud 公式ウェブサイト] |
* [http://owncloud.org/ ownCloud 公式ウェブサイト] |
||
− | * [http://doc.owncloud.org/server/ |
+ | * [http://doc.owncloud.org/server/9.2/admin_manual/ ownCloud 9.2 管理者ドキュメント] |
+ | * [https://docs.nextcloud.com/ nextcloud 公式ウェブサイト] |
||
+ | * [https://docs.nextcloud.com/server/11/admin_manual/ nextcloud 11.0 管理者ドキュメント] |
2017年10月12日 (木) 23:16時点における版
Wikipedia より:
- Nextcloud はファイルホストサービスを作成して使用するためのクライアントサーバーソフトウェアスイートである。広く使われている Dropbox と同じような機能を持ち、フリーでオープンソースであるため、誰でもプライベートサーバーにインストール・使用することができる。Dropbox などのプロプライエタリサービスと異なり、オープンなアーキテクチャを活用してサーバーに機能 (アプリケーション) を簡単に追加することが可能。
Nextcloud と ownCloud の違いについては [1] を見てください。
目次
- 1 要件
- 2 インストール
- 3 セットアップ
- 4 初期化
- 5 セキュリティの強化
- 6 Arch パッケージのアップデートに伴うメンテナンス
- 7 同期
- 8 ヒントとテクニック
- 9 トラブルシューティング
- 9.1 自己署名証明書が使えない
- 9.2 Android デバイスの自己署名証明書
- 9.3 設定ディレクトリに書き込みができない
- 9.4 データディレクトリを作成できない (/path/to/dir)
- 9.5 CSync failed to find a specific file.
- 9.6 ログイン後に白いページが表示される
- 9.7 GUI の同期クライアントで接続できない
- 9.8 ファイルをアップロードすると 'Integrity constraint violation...' エラーが表示される
- 9.9 "Cannot write into apps directory"
- 9.10 nginx.conf に推奨設定を記述したのにセキュリティの警告が表示される
- 9.11 "Reading from keychain failed with error: 'No keychain service available'"
- 10 参照
要件
Nextcloud は以下のコンポーネントを必要とします:
先に進む前にまずは必要なコンポーネントをインストールしてください。
インストール
セットアップ
Nextcloud をセットアップするには PHP が動作するウェブサーバー・データベースサーバーが必要です。
PHP の設定
PHP#gd, php-intl, php-mcrypt を追加モジュールとしてインストールしてください。
使用するデータベースバックエンドに応じて設定が必要です:
- MySQL の場合、PHP#MySQL/MariaDB を見てください。
- PostgreSQL の場合、PHP#PostgreSQL を見てください。
- SQLite の場合、PHP#Sqlite を見てください。
キャッシュを活用することでパフォーマンスを改善することができます。詳しくは公式ドキュメントの メモリキャッシュの設定 を見てください。
データベースの設定
Nextcloud を動かすには SQL データベースをセットアップする必要があります。データベースを設定したら、まずは管理者アカウントを作成する必要があります。
MariaDB
以下は MariaDB のデータベースとユーザーを設定する例です:
$ mysql -u root -p
mysql> CREATE DATABASE `nextcloud` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; mysql> CREATE USER `nextcloud`@'localhost' IDENTIFIED BY 'password'; mysql> GRANT ALL PRIVILEGES ON `nextcloud`.* TO `nextcloud`@`localhost`; mysql> \q
PostgreSQL
以下は PostgreSQL のデータベースとユーザーを設定する例です:
$ sudo -u postgres createuser -h localhost -P nextcloud
Enter password for new role: Enter it again:
$ sudo -u postgres createdb -O nextcloud nextcloud
ウェブサーバーの設定
使用するウェブサーバーによって、必要な設定は変わります。
Apache
Apache の設定ファイルを設定ディレクトリにコピーしてください:
# cp /etc/webapps/nextcloud/apache.example.conf /etc/httpd/conf/extra/nextcloud.conf
必要に応じてファイルの設定を変更してください。デフォルトでは /nextcloud
で /usr/share/webapps/nextcloud
が表示されるエイリアスが記述されています。
設定したら /etc/httpd/conf/httpd.conf
に以下を追加してください:
Include conf/extra/nextcloud.conf
Nextcloud がインストールされているルートディレクトリ (例: /usr/share/webapps/nextcloud
) にウェブサーバーのユーザー http
からアクセスできることを確認してください。
その後 Apache (httpd.service
) を再起動してください。
WebDAV
OwnCloud には WebDAV の実装が付いていますが、Apache の実装と衝突する可能性があります。WebDAV を有効にする場合 (デフォルトでは有効になっていません)、/etc/httpd/conf/httpd.conf
で mod_dav
と mod_dav_fs
モジュールを無効にしてください。詳しくは [3] を参照。
Nginx
クラウドの設定ファイルを保存するための空ディレクトリを作成してください:
# mkdir /etc/nginx/conf.d/
/etc/nginx/nginx.conf
の "http" セクションに以下の行を追加してください:
server_names_hash_bucket_size 64; include conf.d/*.conf;
ドキュメント に従って設定ファイル /etc/nginx/conf.d/nextcloud.conf
を作成してください。Arch のパッケージでは /var/www/
ではなく /usr/share/webapps/
にインストールされるため root
のディレクトリを変える必要があります。
さらに、以下の部分を:
upstream php-handler { server 127.0.0.1:9000; #server unix:/var/run/php5-fpm.sock; }
以下のように変更してください:
upstream php-handler { #server 127.0.0.1:9000; server unix:/run/php-fpm/php-fpm.sock; }
Let’s Encrypt を使用してセキュアな証明書を入手することが推奨されています。#セキュリティの強化を見てください。
PHP-FPM の設定
Nginx#PHP を動かすに書かれているようにして PHP-FPM を設定してください。
/etc/php/php-fpm.d/www.conf
の env[PATH] = /usr/local/bin:/usr/bin:/bin
をアンコメントしてから php-fpm.service
を再起動して変更を適用してください。
初期化
ウェブブラウザで Nextcloud をインストールした PC のアドレスを開いてください (例: https://www.examples.com/nextcloud)。指示に従って管理者アカウントを追加し先に作成したデータベースを選択します。
セキュリティの強化
Nextcloud Hardening and Security の記事に一般的なトピックの説明があります。セキュリティスキャナ も参照。
Let's Encrypt
nginx
こちらのファイル をテンプレートとして使ってクラウド設定の /etc/nginx/conf.d/cloud-initial.conf
を作成してください。テンプレートファイルの "@@FQDN@@" は実際に使用する FQDN に置き換えてください。最初に暗号化されない設定を使うにはサーバーの証明書を生成する必要があります。Let’s Encrypt に書かれている手順に従ってサーバーの暗号化証明書を作成してください。
証明書を作成できたら /etc/nginx/conf.d/cloud-initial.conf
を新しいファイル /etc/nginx/conf.d/cloud.conf
に置き換えてください (it may be safely renamed so long as it does not end in ".conf" or simply deleted)。こちらのファイル をテンプレートとして使うことができます。"@@FQDN@@" は実際に使用する FQDN に置き換えてください。その後 nginx.service
を起動・有効化してください。
uWSGI
uwsgi-plugin-php による uWSGI アプリケーションサーバーを使うことで ownCloud を固有のプロセスで動かすことができます。システム全体の php.ini
を編集しなくても、インスタンスの PHP 設定を定義することができるため、ウェブアプリケーションの設定を分離することが可能です。uWSGI 自体にリソースの使用を制限するための機能が豊富に含まれており、アプリケーションのセキュリティを強化したり、専用のユーザーで動くようにプロセスを分けられます。
PHP-FPM の設定と異なるところは location ~ \.php(?:$|/) {}
ブロックだけです:
location ~ \.php(?:$|/) { include uwsgi_params; uwsgi_modifier1 14; # Avoid duplicate headers confusing OC checks uwsgi_hide_header X-Frame-Options; uwsgi_hide_header X-XSS-Protection; uwsgi_hide_header X-Content-Type-Options; uwsgi_hide_header X-Robots-Tag; uwsgi_pass unix:/run/uwsgi/owncloud.sock; }
それから uWSGI の設定ファイルを作成してください:
/etc/uwsgi/owncloud.ini
[uwsgi] ; load the required plugins plugins = php ; force the sapi name to 'apache', this will enable the opcode cache php-sapi-name = apache ; set master process name and socket ; '%n' refers to the name of this configuration file without extension procname-master = uwsgi %n master = true socket = /run/uwsgi/%n.sock ; drop privileges uid = http gid = http umask = 027 ; run with at least 1 process but increase up to 4 when needed processes = 4 cheaper = 1 ; reload whenever this config file changes ; %p is the full path of the current config file touch-reload = %p ; disable uWSGI request logging ;disable-logging = true ; enforce a DOCUMENT_ROOT php-docroot = /usr/share/webapps/%n ; limit allowed extensions php-allowed-ext = .php ; and search for index.php if required php-index = index.php ; set php configuration for this instance of php, no need to edit global php.ini php-set = date.timezone=Etc/UTC ;php-set = open_basedir=/tmp/:/usr/share/webapps/owncloud:/etc/webapps/owncloud:/dev/urandom php-set = expose_php=false ; avoid security risk of leaving sessions in world-readable /tmp php-set = session.save_path=/usr/share/webapps/owncloud/data ; port of php directives set upstream in /usr/share/webapps/owncloud/.user.ini for use with PHP-FPM php-set = upload_max_filesize=513M php-set = post_max_size=513M php-set = memory_limit=512M php-set = output_buffering=off ; load all extensions only in this instance of php, no need to edit global php.ini ;; required core modules php-set = extension=gd.so php-set = extension=iconv.so ;php-set = extension=zip.so # enabled by default in global php.ini ;; database connectors ;; uncomment your selected driver ;php-set = extension=pdo_sqlite.so ;php-set = extension=pdo_mysql.so ;php-set = extension=pdo_pgsql.so ;; recommended extensions ;php-set = extension=curl.so # enabled by default in global php.ini php-set = extension=bz2.so php-set = extension=intl.so php-set = extension=mcrypt.so ;; required for specific apps ;php-set = extension=ldap.so # for LDAP integration ;php-set = extension=ftp.so # for FTP storage / external user authentication ;php-set = extension=imap.so # for external user authentication, requires php-imap ;; recommended for specific apps ;php-set = extension=exif.so # for image rotation in pictures app, requires exiv2 ;php-set = extension=gmp.so # for SFTP storage ;; for preview generation ;; provided by packages in AUR ; php-set = extension=imagick.so ; opcache php-set = zend_extension=opcache.so ; user cache ; provided by php-acpu, to be enabled **either** here **or** in /etc/php/conf.d/apcu.ini php-set = extension=apcu.so ; per https://github.com/krakjoe/apcu/blob/simplify/INSTALL php-set = apc.ttl=7200 php-set = apc.enable_cli=1 cron2 = minute=-15,unique=1 /usr/bin/php -f /usr/share/webapps/owncloud/cron.php 1>/dev/null
有効化
uWSGI には設定ファイルをインスタンスの識別子として使ってアプリケーションを起動したり有効化できるテンプレートユニットが入っています。例えば:
# systemctl start uwsgi@owncloud.socket
上のコマンドは /etc/uwsgi/owncloud.ini
設定ファイルを参照して必要に応じて起動します。
ブート時にデフォルトで uwsgi サービスを有効化するには、次を実行:
# systemctl enable uwsgi@owncloud.socket
uWSGI#サービスの起動も参照。
ファイルシステムのパーティションの設定
セキュリティを強化するために ownCloud ディレクトリのパーミッションはできるだけ制限的に設定することを推奨します。インストールを行った後、セットアップを開始する前に設定してください。HTTP ユーザーが config/
, data/
, apps/
ディレクトリの所有者となっていれば ownCloud を設定したりデータファイルを作成・修正・削除したり、ownCloud のウェブインターフェイスでアプリをインストールできます [4]。
oc-perms
#!/bin/bash ocpath='/usr/share/webapps/nextcloud' htuser='http' htgroup='http' rootuser='root' printf "Creating possible missing Directories\n" mkdir -p $ocpath/data mkdir -p $ocpath/assets printf "chmod Files and Directories\n" find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640 find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750 printf "chown Directories\n" chown -R ${rootuser}:${htgroup} ${ocpath}/ chown -R ${htuser}:${htgroup} ${ocpath}/apps/ chown -R ${htuser}:${htgroup} ${ocpath}/config/ chown -R ${htuser}:${htgroup} ${ocpath}/data/ chown -R ${htuser}:${htgroup} ${ocpath}/themes/ chown -R ${htuser}:${htgroup} ${ocpath}/assets/ chmod +x ${ocpath}/occ printf "chmod/chown .htaccess\n" if [ -f ${ocpath}/.htaccess ] then chmod 0644 ${ocpath}/.htaccess chown ${rootuser}:${htgroup} ${ocpath}/.htaccess fi if [ -f ${ocpath}/data/.htaccess ] then chmod 0644 ${ocpath}/data/.htaccess chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess fi
標準的なインストール場所からファイルパスをカスタマイズしている場合、上記のスクリプトも修正する必要があります。
fail2ban によるハッキングからの防護
fail2ban のセットアップが強く推奨されています。インストールしたら、以下のファイルを作成してください:
/etc/fail2ban/filter.d/owncloud.conf
[Definition] failregex={"reqId":".*","remoteAddr":".*","app":"core","message":"Login failed: '.*' \(Remote IP: '<HOST>'\)","level":2,"time":".*"} ignoreregex =
/etc/fail2ban/jail.local
[owncloud] enabled = true filter = owncloud port = http,https logpath = /usr/share/webapps/owncloud/data/owncloud.log # optionally whitelist internal LAN IP addresses ignoreip = 192.168.1.1/24
設定後 fail2ban
サービスを再起動してください。以下を実行することで設定をテストできます:
# fail2ban-regex /usr/share/webapps/owncloud/data/owncloud.log /etc/fail2ban/filter.d/owncloud.conf -v
Arch パッケージのアップデートに伴うメンテナンス
Arch の nextcloud パッケージを pacman で更新した場合、ウェブインターフェイスから手動で関連ファイルのアップデートを実行する必要があります。もしくは、シェルから http ユーザーとして /usr/share/webapps/nextcloud/occ upgrade
を実行することでもアップデートできます:
# sudo -u http /usr/share/webapps/nextcloud/occ upgrade
同期
デスクトップ
公式クライアントは owncloud-client または nextcloud-clientAUR パッケージでインストールできます。
カレンダー
Mozilla Thunderbird の Lightning カレンダーを使って ownCloud のカレンダーにアクセスするには以下の URL を使います:
https://ADDRESS/remote.php/caldav/calendars/USERNAME/CALENDARNAME
Kontact や Evolution など CalDAV に対応するプログラムを使って ownCloud のカレンダーにアクセスするには、以下の URL を使います:
https://ADDRESS/remote.php/caldav
詳しくは 公式ドキュメント を見てください。
連絡先
Thunderbird と連絡先を同期するには、SOGo フロントエンド と Lightning エクステンションをインストールして公式ドキュメントの 手順 に従う必要があります。
davfs2 でファイルをマウントする
ownCloud を永続的にマウントしたい場合、まず davfs2 をインストールしてください (Davfs に説明があります)。
もし ownCloud が https://own.example.com
にある場合、WebDAV の URL は https://own.example.com/remote.php/webdav
になります (ownCloud 6.0 現在)。
ownCloud をマウントするには、次のコマンドを使います:
# mount -t davfs https://own.example.com/remote.php/webdav /path/to/mount
/etc/fstab
にエントリを作成することもできます:
/etc/fstab
https://own.example.com/remote.php/webdav /path/to/mount davfs rw,user,noauto 0 0
Android
小額で使うことができる公式 Android アプリが Play ストア にあり、無料で使えるアプリが F-Droid にあります。
連絡先とカレンダーの同期を有効にするには:
- Android 4 以上を使っている場合:
- 古いバージョンが対象ですが、こちらの記事 には有用な情報が記載されています。
- 4.0 以下のバージョンの Android を使っていて、フリーのソフトウェアを使いたい場合、カレンダーと連絡先の同期には aCal を、カレンダーだけの同期には CalDAV Sync Adapter (F-Droid) を試して下さい。フリーでないソフトウェアを使う気があるのであれば、CardDAV-Sync と CalDAV-Sync の使用が 推奨 されています。
SABnzbd
SABnzbd を使う場合、sabnzbd.ini
ファイルに以下を設定すると良いでしょう:
folder_rename 0
というのは ownCloud はアップロードされたファイルを速攻でスキャンするからです。展開された接頭辞などを SABnzbd が削除することを予防します。
ヒントとテクニック
サブディレクトリで ownCloud を実行
httpd.conf
から読み込まれるデフォルトの owncloud.conf
では、ownCloud はポート 80 と localhost ドメインを使用します。
サブディレクトリで ownCloud を使いたい場合、/etc/httpd/conf/extra/owncloud.conf
を編集して <VirtualHost *:80> ... </VirtualHost>
という部分をコメントアウトしてください。
uwsgi で owncloud を使用する場合、以下の nginx 設定が使えます:
/etc/nginx/conf.d/owncloud.conf
location = /.well-known/carddav { return 301 $scheme://$host/owncloud/remote.php/dav; } location = /.well-known/caldav { return 301 $scheme://$host/owncloud/remote.php/dav; } location /.well-known/acme-challenge { } location ^~ /owncloud { root /usr/share/webapps; # set max upload size client_max_body_size 512M; fastcgi_buffers 64 4K; # Disable gzip to avoid the removal of the ETag header gzip off; # Uncomment if your server is build with the ngx_pagespeed module # This module is currently not supported. #pagespeed off; location /owncloud { rewrite ^ /owncloud/index.php$uri; } location ~ ^/owncloud/(?:build|tests|config|lib|3rdparty|templates|data)/ { deny all; } location ~ ^/owncloud/(?:\.|autotest|occ|issue|indie|db_|console) { deny all; } location ~ ^/owncloud/(?:updater|ocs-provider)(?:$|/) { try_files $uri/ =404; index index.php; } location ~ ^/owncloud/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) { include uwsgi_params; uwsgi_modifier1 14; # Avoid duplicate headers confusing OC checks uwsgi_hide_header X-Frame-Options; uwsgi_hide_header X-XSS-Protection; uwsgi_hide_header X-Content-Type-Options; uwsgi_hide_header X-Robots-Tag; uwsgi_pass unix:/run/uwsgi/owncloud.sock; } # Adding the cache control header for js and css files # Make sure it is BELOW the PHP block location ~* \.(?:css|js) { try_files $uri /owncloud/index.php$uri$is_args$args; add_header Cache-Control "public, max-age=7200"; # Add headers to serve security related headers (It is intended # to have those duplicated to the ones above) # Before enabling Strict-Transport-Security headers please read # into this topic first. # add_header Strict-Transport-Security "max-age=15768000; # includeSubDomains; preload;"; add_header X-Content-Type-Options nosniff; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Robots-Tag none; add_header X-Download-Options noopen; add_header X-Permitted-Cross-Domain-Policies none; # Optional: Don't log access to assets access_log off; } location ~* \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg) { try_files $uri /owncloud/index.php$uri$is_args$args; # Optional: Don't log access to other assets access_log off; } }
Docker
Docker の ownCloud あるいは Nextcloud リポジトリを見てください。
ファイルマネージャからアップロード・共有
shareLinkCreator はサポートされているファイルマネージャから ownCloud にファイルをアップロードする機能を提供します。アップロードしたファイルのリンクをメールなどで配ることが可能です。
AJAX から Cron に切り替える
Nextcloud では定期的に実行する必要があるタスクが存在しますが、デフォルトでは AJAX を使って実行されます。AJAX は信頼性に欠けるため Cron や systemd/タイマーを使うことを推奨します。
/etc/systemd/system/nextcloud-cron.timer
[Unit] Description=Runs Nextcloud tasks regularly [Timer] OnBootSec=10min OnUnitActiveSec=15min [Install] WantedBy=timers.target
/etc/systemd/system/nextcloud-cron.service
[Unit] Description=Nextcloud scheduled tasks [Service] Type=oneshot User=http Group=http ExecStart=/usr/bin/php -f /usr/share/webapps/nextcloud/cron.php
もしくは以下の cron ジョブを設定:
*/15 * * * * php -f /usr/share/webapps/nextcloud/cron.php
Collabora Online Office の統合
nextcloud-app-collabora-onlineAUR をインストールしてウェブサーバーの Nextcloud の設定を編集します。Nginx の場合:
# static files location ^~ /loleaflet { proxy_pass https://localhost:9980; proxy_set_header Host $http_host; } # WOPI discovery URL location ^~ /hosting/discovery { proxy_pass https://localhost:9980; proxy_set_header Host $http_host; } # websockets, download, presentation and image upload location ^~ /lool { proxy_pass https://localhost:9980; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; }
Apache の場合は こちら を見てください。docker デーモンを使っている場合、Collabora Online の最新の docker イメージを pull できます。2番目のコマンドのドメイン名はあなたの Nextcloud サーバーのドメイン名に置き換えてください:
docker pull collabora/code docker run -t -d -p 127.0.0.1:9980:9980 -e 'domain=localhost' --net host --restart always --cap-add MKNOD collabora/code
docker イメージを更新する際は同じコマンドを実行します。ただし旧イメージの実行中プロセスを全て終了してください:
docker ps docker stop CONTAINER_ID docker rm CONTAINER_ID
これで Nextcloud インスタンスで Collabora Online アプリを有効にできます。最後に管理者の設定で Collabora Online アプリに関する設定を行ってください。
トラブルシューティング
自己署名証明書が使えない
ownCloud は cURL や SabreDAV を使って WebDAV が有効になっているかチェックします。(LAMP の記事に書かれているように) 自己署名証明書で SSL/TLS を使って、ownCloud の管理者ページにアクセスすると、以下のエラーメッセージが表示されます:
Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken.
LAMP のチュートリアルにしたがって設定を行っている場合、以下の手順を実行してください:
証明書のためのローカルディレクトリを作成して、そこに LAMP の証明書をコピーします。これによって ca-certificates
のアップデートによって証明書が上書きされるのを防ぎます。
# cp /etc/httpd/conf/server.crt /usr/share/ca-certificates/WWW.EXAMPLE.COM.crt
WWW.EXAMPLE.COM.crt を /etc/ca-certificates.conf
に追加:
WWW.EXAMPLE.COM.crt
そして証明書を更新:
# update-ca-certificates
httpd サービスを再起動して証明書を有効にしてください。
これで動作しない場合は /etc/php/php.ini
で mod_curl を無効化してみてください。
Android デバイスの自己署名証明書
LAMP#TLS/SSL に書かれているように SSL のセットアップをした場合、古いバージョンの DAVdroid では証明書が信頼できないとして接続が拒否されます。以下のようにサーバーに証明書を作成できます:
# openssl x509 -req -days 365 -in /etc/httpd/conf/server.csr -signkey /etc/httpd/conf/server.key -extfile android.txt -out CA.crt # openssl x509 -inform PEM -outform DER -in CA.crt -out CA.der.crt
android.txt
ファイルに以下を記述してください:
basicConstraints=CA:true
そして Android 端末に CA.der.crt
をインポートしてください:
Android 端末の SD カードに CA.der.crt
ファイルを保存してください (メールの添付ファイルなどを使って保存してください)。ファイルはルートディレクトリに配置してください。そして Settings > Security > Credential storage から Install from device storage を選択します。.crt
ファイルが検出されて、証明書の名前の入力が求められます。証明書をインポートしたら、Settings > Security > Credential storage > Trusted credentials > User から確認できるはずです。
ソース: [6]
CAdroid を使ってサーバーから直接証明書をインポートする方法もあります。
設定ディレクトリに書き込みができない
httpd の設定ファイル (owncloud.conf
など) を確認してください。以下の文字列に設定ディレクトリ (デフォルトでは /etc/webapps
) を追加してください:
php_admin_value open_basedir "/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/path/to/dir/"
変更を適用するには httpd あるいは php-fpm サービスを再起動します。
データディレクトリを作成できない (/path/to/dir)
httpd の設定ファイル (owncloud.conf
など) を確認してください。以下の文字列にデータディレクトリを追加してください:
php_admin_value open_basedir "/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/path/to/dir/"
変更を適用するには httpd あるいは php-fpm サービスを再起動します。
また PHP 7 はデフォルトでは open_basedir を使用しないため、必要なデータディレクトリの所有者・所有ユーザーを root:http
にしてパーミッションを 770 に変更することでも解決できます (http はウェブサーバーを実行するユーザーのグループに置き換えてください)。
CSync failed to find a specific file.
おそらく証明書に問題があります。証明書を再度作成して、名前を空にしないようにしてください。そうしないとエラーがまた発生します。
# openssl req -new -x509 -nodes -newkey rsa:4096 -keyout server.key -out server.crt
ログイン後に白いページが表示される
おそらく新しくインストールしたアプリが原因です。修正するには、こちら に書かれているように occ コマンドを使用します。アプリを全て確認するには:
# sudo -u http php /usr/share/webapps/owncloud/occ app:list
問題のアプリを無効化するには (ownCloud を標準のディレクトリにインストールした場合):
# sudo -u http php /usr/share/webapps/owncloud/occ app:disable <nameOfExtension>
もしくは phpMyAdmin を使って oc_appconfig
テーブルを編集するか (運が良いことにテーブルに edit オプションがある場合) mysql で手動で修正してください:
$ mysql -u root -p owncloud MariaDB [owncloud]> delete from oc_appconfig where appid='<nameOfExtension>' and configkey='enabled' and configvalue='yes'; MariaDB [owncloud]> insert into oc_appconfig (appid,configkey,configvalue) values ('<nameOfExtension>','enabled','no');
テーブルから関連する設定が削除されるので、後でまた追加してください。
GUI の同期クライアントで接続できない
HTTP のベーシック認証を使っている場合、status.php
が対象から外れていることを確認してください。このファイルは誰からでもアクセスできるようにしておく必要があります [7]。
ファイルをアップロードすると 'Integrity constraint violation...' エラーが表示される
ownCloud の同期クライアントで以下のエラーが表示されることがあります:
SQLSTATE[23000]: Integrity constraint violation: ... Duplicate entry '...' for key 'fs_storage_path_hash')...
File Locking アプリの問題が原因です。ウェブーサーバーの設定の衝突が発生しているのに対処できていません。エラーが発生しない Transactional File Locking が存在しますが、Redis の php キャッシュを使う必要があります。redis と php-redisAUR をインストールして、現在使っている php のキャッシュをコメントアウトして、/etc/php/conf.d/redis.ini
から extension=redis.so
をアンコメントしてください。そして config.php
に以下の変更を加えます:
'memcache.local' => '\OC\Memcache\Redis', 'filelocking.enabled' => 'true', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => array( 'host' => 'localhost', 'port' => 6379, 'timeout' => 0.0, ),
設定したら Redis を再起動:
# systemctl enable redis.service # systemctl start redis.service
最後に、File Locking アプリを無効化して、Transational File Locking を使うようにしてください。
管理者ページのサーバーステータスに 'Transactional File Locking Enabled' が表示され、同期の問題が消えるはずです。
"Cannot write into apps directory"
公式の管理者マニュアル に書かれているように、http ユーザーからアプリディレクトリに書き込みができるようにするか、appstoreenabled
を false
に設定する必要があります。
また、ドキュメントには書かれていませんが、/etc/php/php.ini
の open_basedir
行にディレクトリを指定してください。
きれいな解決方法としてパッケージによってインストールされた /usr/share/webapps/owncloud/apps
ディレクトリの所有者は root にしたまま、ユーザーがインストールしたアプリは http が所有者となる /var/www/owncloud/apps
などに入れる方法があります。それから appstoreenabled
を true
に設定してアプリのパッケージをアップグレードすれば上手く動作するはずです。/etc/webapps/owncloud/config/config.php
の該当する行:
'apps_paths' => array ( 0 => array ( 'path' => '/usr/share/webapps/owncloud/apps', 'url' => '/apps', 'writable' => false, ), 1 => array ( 'path' => '/var/www/owncloud/apps', 'url' => '/wapps', 'writable' => true, ), ),
/etc/php/php.ini
の open_basedir
行の例:
open_basedir = /srv/http/:/usr/share/webapps/:/var/www/owncloud/apps/
ディレクトリのパーミッション:
$ ls -ld /usr/share/webapps/owncloud/apps /var/www/owncloud/apps/
drwxr-xr-x 26 root root 4096 des. 14 20:48 /usr/share/webapps/owncloud/apps drwxr-xr-x 2 http http 48 jan. 20 20:01 /var/www/owncloud/apps/
nginx.conf に推奨設定を記述したのにセキュリティの警告が表示される
管理者マニュアルにしたがって Strict-Transport-Security
, X-Content-Type-Options
, X-Frame-Options
, X-XSS-Protection
, X-Robots-Tag
を設定しても管理者ページの上部に警告が表示されることがあります。
考えられる原因として ownCloud 自身が設定を行っていて、uWSGI によって nginx に設定が重複して追加されてしまっている可能性があります:
$ curl -I https://domain.tld
... X-XSS-Protection: 1; mode=block X-Content-Type-Options: nosniff X-Frame-Options: Sameorigin X-Robots-Tag: none Strict-Transport-Security: max-age=15768000; includeSubDomains; preload; X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block X-Robots-Tag: none
fast_cgi のサンプル設定には重複を避けるためのパラメータが存在しますが (fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice
)、uwsgi と nginx を使用する場合、nginx.conf
の uwsgi の部分に以下の修正を加えることで解決します:
/etc/nginx/nginx.conf
... # pass all .php or .php/path urls to uWSGI location ~ ^(.+\.php)(.*)$ { include uwsgi_params; uwsgi_modifier1 14; # hode following headers received from uwsgi, because otherwise we would send them twice since we already add them in nginx itself uwsgi_hide_header X-Frame-Options; uwsgi_hide_header X-XSS-Protection; uwsgi_hide_header X-Content-Type-Options; uwsgi_hide_header X-Robots-Tag; uwsgi_hide_header X-Frame-Options; #Uncomment line below if you get connection refused error. Remember to commet out line with "uwsgi_pass 127.0.0.1:3001;" below uwsgi_pass unix:/run/uwsgi/owncloud.sock; #uwsgi_pass 127.0.0.1:3001; } ...
"Reading from keychain failed with error: 'No keychain service available'"
Gnome の場合、libgnome-keyring と gnome-keyring パッケージをインストールすることで解決します。KDE の場合、libgnome-keyring と qtkeychain パッケージをインストールしてください。