(Ubuntu)- Ubuntu Server 架站學習筆記 -(9) – 使用 Nextcloud 架設自己的雲端硬碟

(Ubuntu)- Ubuntu Server 架站學習筆記 -(9) – 使用 Nextcloud 架設自己的雲端硬碟

(Ubuntu)- Ubuntu Server 架站學習筆記 -(9) – 使用 Nextcloud 架設自己的雲端硬碟

 

最近電腦升級,把舊電腦用來學習架伺服器,發文當做學習記錄,也給後來學習的人少花些時間

此筆記,不一定正確但會在學習過程中修正,也無順序可言,遇到問題才會去爬文看書學習

 

 

現在網路上已經愈來愈多的雲端硬碟,例如Dropbox、Google Drive、One Drive…等,而假如想要使用私人伺服器來架設自己的雲端硬碟,目前來說較多人選的是 Miniyun 和 Nextcloud

在這站長選擇的是 Netcloud 原因也很簡單,因為在查 Miniyun 資料時,一些配套還要網找 ,而最重要的是官網上不去,不想花時間安裝測試,最後又有很多問題,如果以後網上資料齊全了,再來測試好不好用再發文

而 Nextcloud 其功能非常多元,可在頁面上直接瀏覽圖片、文件以及在線觀看上傳的影片,而且能像 Dropbox 與 Google Drive 一樣支援資料夾同步功能,另外還能透過安裝 App 達到在線編輯 Excel 或是 Word 相關功能,是一個強大的開源雲端硬碟軟體


目前己安裝沒什麼問題,流程如下,因最近比較忙,還沒有實際使用,應該還有別的問題,要等過幾天測試再補充

 

官方網站:https://nextcloud.com

在線試用:https://demo.nextcloud.com/

程式碼:https://github.com/nextcloud

 

  ~~~下面本文正式開始~~~

 

第一步:

因為 Nextcloud 是 PHP 寫的,而資料庫為 Mysql 環境,所以要先安裝一下 LEMP

網上資料很多,上網找一下就有了,目前站長還沒整理好,因為之前查的資料太多太雜了

 

第二步:

Nextcloud 還需要一些 PHP 套件才能夠使用 輸入以下指令安裝:

 

sudo apt-get install php-xml php-zip php-mbstring php-curl php-gd

 

第三步:

到官方網站下載安裝包 ( https://nextcloud.com/install/ )

點選 [ Download for server ] 之後點 [ Download Nextcloud ]

 

第四步:

將下載完的安裝包解壓縮並上傳至伺服器的 PHP 資料夾中 ( 如果是 LEMP 環境預設是在 /var/www/html 中 )

※這邊範例以放在 /var/www/html/nextcloud 當作範例

 

第五步:

接著將 Nextcloud 的資料夾擁有者轉給 Nginx:

 

sudo chown -R www-data nextcloud

 

然後 Nginx 需要設定 rewrite 轉至 index.php 輸入指令修改設定:

 

sudo nano /etc/nginx/sites-available/default

 

將原本的設定加上紅色字的部份 ( 如果走 https 協定請把 fastcgi_param HTTPS on ; 的註解去除 )

 

server {
listen 80 default_server;
listen [::]:80 default_server;

root /var/www/html;

index index.php index.html index.htm index.nginx-debian.html;

server_name _;

location / {
try_files $uri $uri/ =404;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}

location ~ /\.ht {
deny all;
}

location ^~ /nextcloud {
# set max upload size
client_max_body_size 512M;
fastcgi_buffers 64 4K;

# Enable gzip but do not remove ETag headers
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;

# Uncomment if your server is build with the ngx_pagespeed module
# This module is currently not supported.
#pagespeed off;

location /nextcloud {
rewrite ^ /nextcloud/index.php$request_uri;
}

location ~ ^/nextcloud/( ?:build | tests | config | lib | 3rdparty | templates | data )/ {
deny all;
}

location ~ ^/nextcloud/( ?:\.| autotest | occ | issue | indie | db_ | console ) {
deny all;
}

location ~ ^/nextcloud/( ?:index | remote | public | cron | core/ajax/update | status | ocs/v[12] | updater/.+ | ocs-provider/.+)\.php(?:$|/) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name ;
fastcgi_param PATH_INFO $fastcgi_path_info;
# fastcgi_param HTTPS on;
# Avoid sending the security headers twice
fastcgi_param modHeadersAvailable true;
fastcgi_param front_controller_active true;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
}

location ~ ^/nextcloud/(?:updater|ocs-provider)(?:$|/) {
try_files $uri/ =404;
index index.php;
}

# Adding the cache control header for js and css files
# Make sure it is BELOW the PHP block
location ~ \.(?:css|js|woff|svg|gif)$ {
try_files $uri /nextcloud/index.php$request_uri;
add_header Cache-Control "public, max-age=15778463";
# 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-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 ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
try_files $uri /nextcloud/index.php$request_uri;
# Optional: Don't log access to other assets
access_log off;
}
}
}

 

修改完成後輸入以下指令讓 nginx 重新讀取設定檔

 

sudo systemctl reload nginx

 

此時開啟網頁 http://your_host/nextcloud

然後設定自己想要的管理員帳號密碼、雲端硬碟資料儲存位置、以及資料庫帳號密碼,輸入完成後按 [Finish setup]

(這需要等待一小段時間)

接著就能夠進入雲端硬碟頁面中了

 

第六步:

登入後點選右上的 Users 可以新增使用者

 

第七步:( 目前還未安裝測試好不好用 )

點選右上 Apps 可以設定哪些 App 功能要開啟哪些功能不要開啟,且能點左邊的選單安裝自己想要的新 App

例如在線編輯 Excel 與 Word 的App 可以點選 [Office & Text]  >  [Collabora Online] 來進行安裝

( 詳見:https://nextcloud.com/collaboraonline/ )

 

PS:總感覺有些雞肋,大多現在電腦、手機都可以看文檔

 

 

 

免責聲明:

1.本影像檔案皆從網上搜集轉載,不承擔任何技術及版權問題。

2.如有下載連結僅供寬頻測試研究用途,請下載後在24小時內刪除,請勿用於商業。

3.若侵犯了您的合法權益,請來信通知我們,我們會及時刪除,給您帶來的不便,深表歉意。



發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *