.htaccess
によって一部の設定を指定するため、Apacheサーバーソフトウェアを使用する際、NextCloudサーバー自体の設定項目をそのまま使用することができます。Nginxは近年急成長中のWebサーバーソフトウェアであり、Apacheに比べてインストール設定が簡単、リソース占有が少ない、ロードバランシング機能がより強力であるなどのメリットがあります。NextCloudサーバー内の.htaccess
設定をNginxの設定として移行しても、NextCloudサーバーの実行は問題なくサポートされます。ここではNginxサーバーソフトウェアを使用するとともに、完全なNginx設定の例を参考までに示します。設定項目 | 値 |
名前 | カスタマイズしたバケット名(例:nextcloud)を入力します。この名前は決定すると変更できませんのでご注意ください |
所属リージョン | 購入したCVMの所属リージョンと同じものにします |
その他 | デフォルトを維持します |
yum install nginx
Y
を入力してエンターを押し、インストールを確認します(以下同様)。Is this ok [y/d/N]:
Complete![root@VM-0-10-centos ~]#
nginx -v
nginx version: nginx/1.16.1
yum install epel-release yum-utils
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Ctrl-C
でキャンセルし、再度このコマンドを実行することができます(以下同様)。yum-config-manager --enable remi-php74
yum install php php-fpm
php -v
PHP 7.4.8 (cli) (built: Jul 9 2020 08:57:23) ( NTS )Copyright (c) The PHP GroupZend Engine v3.4.0, Copyright (c) Zend Technologies
yum install php-xml php-gd php-mbstring php-mysqlnd php-intl php-zip
php -m
yum install <php-module-name>
を繰り返し実行します。/var/www/
ディレクトリ下にアップロードします。アップロードは以下の方法で行うことができます。wget
コマンドを使用して、インストールパッケージのダウンロードとサーバーへのアップロードを直接行います。例えば/var/www/
ディレクトリに進んだ後、コマンドwget https://download.nextcloud.com/server/releases/nextcloud-19.0.1.zip
を実行します。/var/www/
ディレクトリにアップロードします。yum install lrzsz
を実行してlrzszをインストールします。cd /var/www/
を実行して目的のディレクトリに進みます。rz -bye
を実行し、続いてSSHツールから、ローカルにダウンロードするNextCloudサーバーインストールパッケージを選択します(この操作はSSHツールによって多少異なります)。unzip nextcloud-<version>.zip
を実行してインストールパッケージを解凍します。例えばunzip nextcloud-19.0.1.zip
などとします。vim /etc/php-fpm.d/www.conf
を実行してPHP-FPMの設定ファイルを開き、設定項目を順に変更します(vimの具体的な使用方法については関連資料をご参照ください。この設定ファイルの変更は他の方法でも行うことができます)。user = apache
をuser = nginx
に変更します。group = apache
をgroup = nginx
に変更します。:wq
を入力してファイルを保存して終了します(vimの詳細な操作ガイドについては関連ドキュメントをご参照ください)。chown -R nginx:nginx /var/lib/php
systemctl enable php-fpm # コマンド1
systemctl start php-fpm # コマンド2
chown -R nginx:nginx /var/www
/etc/nginx/nginx.conf
をバックアップします。次の方法で行うことができます。cp /etc/nginx/nginx.conf ~/nginx.conf.bak
を実行し、現在の設定ファイルをホーム(HOME)ディレクトリにバックアップします。/etc/nginx/nginx.conf
を変更するか、または次の内容に置き換えます。# For more information on configuration, see:# * Official English Documentation: http://nginx.org/en/docs/# * Official Russian Documentation: http://nginx.org/ru/docs/user nginx;worker_processes auto;error_log /var/log/nginx/error.log;pid /run/nginx.pid;# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.include /usr/share/nginx/modules/*.conf;events {worker_connections 1024;}http {log_format main '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';access_log /var/log/nginx/access.log main;sendfile on;tcp_nopush on;tcp_nodelay on;keepalive_timeout 65;types_hash_max_size 2048;include /etc/nginx/mime.types;default_type application/octet-stream;# Load modular configuration files from the /etc/nginx/conf.d directory.# See http://nginx.org/en/docs/ngx_core_module.html#include# for more information.include /etc/nginx/conf.d/*.conf;server {listen 80 default_server;listen [::]:80 default_server;server_name _;root /var/www/nextcloud;add_header Referrer-Policy "no-referrer" always;add_header X-Content-Type-Options "nosniff" always;add_header X-Download-Options "noopen" always;add_header X-Frame-Options "SAMEORIGIN" always;add_header X-Permitted-Cross-Domain-Policies "none" always;add_header X-Robots-Tag "none" always;add_header X-XSS-Protection "1; mode=block" always;client_max_body_size 512M;fastcgi_buffers 64 4K;gzip on;gzip_vary on;gzip_comp_level 4;gzip_min_length 256;gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;# Load configuration files for the default server block.include /etc/nginx/default.d/*.conf;location / {try_files $uri $uri/ =404;index index.php;}location ~ ^\\/(?:build|tests|config|lib|3rdparty|templates|data)\\/ {deny all;}location ~ ^\\/(?:\\.|autotest|occ|issue|indie|db_|console) {deny all;}location ~ ^\\/(?:index|remote|public|cron|core\\/ajax\\/update|status|ocs\\/v[12]|updater\\/.+|oc[ms]-provider\\/.+)\\.php(?:$|\\/) {fastcgi_split_path_info ^(.+?\\.php)(\\/.*|)$;set $path_info $fastcgi_path_info;try_files $fastcgi_script_name =404;include fastcgi_params;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;fastcgi_param PATH_INFO $path_info;fastcgi_param modHeadersAvailable true;fastcgi_pass 127.0.0.1:9000;fastcgi_intercept_errors on;fastcgi_request_buffering off;}location ~ ^\\/(?:updater|oc[ms]-provider)(?:$|\\/) {try_files $uri/ =404;index index.php;}location ~ \\.(css|js|svg|gif)$ {add_header Cache-Control "max-age=15778463";}location ~ \\.woff2?$ {add_header Cache-Control "max-age=604800";}}# Settings for a TLS enabled server.## server {# listen 443 ssl http2 default_server;# listen [::]:443 ssl http2 default_server;# server_name _;# root /usr/share/nginx/html;## ssl_certificate "/etc/pki/nginx/server.crt";# ssl_certificate_key "/etc/pki/nginx/private/server.key";# ssl_session_cache shared:SSL:1m;# ssl_session_timeout 10m;# ssl_ciphers HIGH:!aNULL:!MD5;# ssl_prefer_server_ciphers on;## # Load configuration files for the default server block.# include /etc/nginx/default.d/*.conf;## location / {# }## error_page 404 /404.html;# location = /40x.html {# }## error_page 500 502 503 504 /50x.html;# location = /50x.html {# }# }}
systemctl enable nginx
systemctl start nginx
config.php
を作成し、次の内容を入力して、メモの内容に基づいて関連の値を変更します。<?php$CONFIG = array('objectstore' => array('class' => '\\\\OC\\\\Files\\\\ObjectStore\\\\S3','arguments' => array('bucket' => 'nextcloud-1250000000', // バケット名(スペース名)'autocreate' => false,'key' => 'AKIDxxxxxxxx', // ユーザーのSecretIdに置き換えます'secret' => 'xxxxxxxxxxxx', // ユーザーのSecretKeyに置き換えます'hostname' => 'cos.<Region>.myqcloud.com', // <Region>を所属リージョンに変更します(ap-shanghaiなど)'use_ssl' => true,),),);
/var/www/nextcloud/config/
ディレクトリ下にアップロードします(ファイル名はconfig.php
のままにしておきます)。SFTPまたはSCPソフトウェアでファイルをアップロードするか、またはrz -bye
コマンドによってアップロードすることができます。
3. 次のコマンドを実行し、設定ファイルの所有者を変更します。chown nginx:nginx /var/www/nextcloud/config/config.php
/var/www/nextcloud/config/config.php
設定ファイル内のtrusted_domains
を変更することができます。詳細については、NextCloud公式ドキュメントをご参照ください。設定項目 | 値 |
データディレクトリ | /var/www/nextcloud/data(デフォルトを維持) |
データベース設定 | MySQL/MariaDB |
データベースユーザー | root |
データベースパスワード | TencentDB for MySQLを初期化した際に入力したrootパスワード |
データベース名 | nextcloud(またはその他の使用されていないデータベース名) |
データベースホスト(デフォルトではlocalhostと表示) | TencentDB for MySQLのプライベートネットワークアドレス |
yum install php-posix
crontab -u nginx -e
i
キーを押して編集モードに入り、次の内容の1行を挿入します。*/5 * * * * php -f /var/www/nextcloud/cron.php
ESC
を押して編集モードを終了し、:wq
を入力して保存し、終了します(vi/vimの詳細な操作ガイドについては関連ドキュメントをご参照ください)。
上記の設定ではNextCloud公式が推奨する5分に1回の実行を使用しています(分数は5の整数倍)。5分後にバックエンドタスクの実行が完了すると、ブラウザを開いてNextCloudサーバーにログインできるようになります。右上隅にあるユーザー名のイニシャルのアイコンをクリックし、設定に進み、左側メニューから基本設定に進むと、バックエンドタスクのところにデフォルトでCronが選択されていることを確認できます。yum install php-pecl-apcu
systemctl restart nginx
systemctl restart php-fpm
vim /var/www/nextcloud/config/config.php
を実行し、NextCloudサーバーの設定ファイルを開き、$CONFIG = array (
の中に'memcache.local' => '\\OC\\Memcache\\APCu',
という1行を追加します。その後ファイルを保存して終了します。
vim /etc/php.d/40-apcu.ini
を実行し、PHP APCuの設定ファイルを開き、;apc.enable_cli=0
をapc.enable_cli=1
に変更し(同時に前のセミコロンを削除する必要があることにご注意ください)、保存して終了します。パス/etc/php.d/40-apcu.ini
が存在しない場合は、apcまたはapcuの文字がある.ini
設定ファイルをご自身で/etc/php.d/
ディレクトリから見つけて編集してください。
この記事はお役に立ちましたか?