====== NextCloud 安裝設定紀錄 ======
===== 使用 Ubuntu + Docker 安裝方式 =====
* 參考 - https://github.com/nextcloud/all-in-one
* 安裝 docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt install docker.io docker-compose-plugin
* 將 jonathan 加入 docker
sudo usermod -aG docker jonathan
* 依據 [[https://github.com/nextcloud/all-in-one/blob/main/compose.yaml|compose.yaml]] 檔案內容進行調整
services:
nextcloud-aio-mastercontainer:
image: nextcloud/all-in-one:latest
init: true
restart: always
container_name: nextcloud-aio-mastercontainer
volumes:
- nextcloud_aio_mastercontainer:/mnt/docker-aio-config
- /var/run/docker.sock:/var/run/docker.sock:ro
ports:
- 8080:8080
environment:
- SKIP_DOMAIN_VALIDATION=true
- NEXTCLOUD_DATADIR=/opt/stacks/nextcloud/ncdata
- NEXTCLOUD_MOUNT=/mnt/
volumes:
nextcloud_aio_mastercontainer:
name: nextcloud_aio_mastercontainer
* 連上 https://server_ip:8080
* 如果第一時間沒有看到 AIO password 可以透過以下方式取得
sudo docker exec nextcloud-aio-mastercontainer grep password
==== 參考網址 ====
* https://github.com/nextcloud/all-in-one/discussions/1786
===== 使用 PVE 內的 CT Templates 安裝方式 =====
* CT Templates : debian-10-turnkey-nextcloud_16.1-1_amd64.tar.gz
* 如果沒有正式 SSL 憑證, 須將設定安裝 NextCloud 的 Domain Name 或 IP 必須要加入 config 定義的 trusted_domains 內 Exp. 192.168.11.24
cd /var/www/nextcloud
vi config/config.php
:
'trusted_domains' =>
array (
0 => 'localhost',
1 => 'nextcloud.ichiayi.com',
2 => '192.168.11.24',
),
'datadirectory' => '/var/www/nextcloud-data',
'dbtype' => 'mysql',
:
===== 解決安全設定警告項目 =====
* 缺少安裝 bcmath PHP 套件問題
* 安裝 php-bcmath
apt install php-bcmath
* 重啟 apache
systemctl restart apache2
* 新增「default_phone_region」
* 編輯 config.php vi /var/www/nextcloud/config/config.php
:
:
'default_phone_region' => 'TWN',
);
===== 重新設定 admin 密碼 =====
* 參考 - https://docs.nextcloud.com/server/latest/admin_manual/configuration_user/reset_admin_password.html
* 在主機內使用 www-data 身分直接用命令執行重設密碼
apt install sudo
sudo -u www-data php /var/www/nextcloud/occ user:resetpassword admin
* ++實際操作紀錄|
root@nextcloud ~# sudo -u www-data php /var/www/nextcloud/occ user:resetpassword admin
Enter a new password:
Confirm the new password:
Successfully reset password for admin
++
===== 設定 Let's Encrypt SSL 憑證 =====
* 參考 - https://nextcloudpi-documentation-taiwan-traditional-chinese.readthedocs.io/zh_TW/latest/Configure/How-to-get-certificate-with-Letsencrypt-using-DNS-to-verify-domain/
* Exp. 使用 Cloudflare 管理 DNS , 要申請 nextcloud.ichiayi.com 的 SSL 憑證, 執行方式
-
apt install certbot python-certbot-apache
certbot -d nextcloud.ichiayi.com --manual --preferred-challenges dns certonly
- 需要依照訊息顯示至 DNS 增加 TXT Record Exp.
_acme-challenge.nextcloud.ichiayi.com
yWQSKEASom2ngmRnohuDjVGJPA08d1DfZovl-JKnk-U
- 編輯 nextcloud.conf 定義憑證檔路徑
vi /etc/apache2/sites-enabled/nextcloud.conf
:
SSLEngine on
ServerAdmin webmaster@localhost
DocumentRoot /var/www/nextcloud/
SSLCertificateFile /etc/letsencrypt/live/nextcloud.ichiayi.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/nextcloud.ichiayi.com/privkey.pem
:
- 編輯 config 檔案將正式憑證的網址設定為 trusted_domains 的第一項
vi /var/www/nextcloud/config/config.php
:
'trusted_domains' =>
array (
0 => 'nextcloud.ichiayi.com',
1 => '192.168.11.24',
),
'datadirectory' => '/var/www/nextcloud-data',
'dbtype' => 'mysql',
:
- 重新啟動 apache2
service apache2 restart
{{tag>nextcloud tips}}