如何在 Ubuntu 16.04 上配置和安裝 ownCloud
在這篇文章中,我們將學習如何在 Ubuntu 16.04 上配置和安裝 ownCloud。ownCloud 是一個檔案共享伺服器,允許使用者將個人內容儲存在中心儲存位置,就像 Google Drive、Dropbox 等一樣。主要區別在於 ownCloud 是一個免費的開源應用程式,可以配置在我們自己的環境中,我們可以控制資料並透過有限的訪問許可權來保護它們。
先決條件
- 我們需要以下環境來設定和配置 ownCloud。
- 已安裝 Ubuntu 16.04 並進行初始設定,且使用者具有 sudo 許可權
- 需要安裝 LAMP(Linux、Apache、MySQL 和 PHP)。
- 用於保護 ownCloud 站點的 SSL 證書。
在 Ubuntu 上安裝 ownCloud
預設情況下,ownCloud 包在 Ubuntu 預設儲存庫中可用,ownCloud 也維護其為 Ubuntu 的專用儲存庫。
要將儲存庫新增到本地機器,我們需要執行以下命令:
$ curl https://download.owncloud.org/download/repositories/stable/Ubuntu_16.04/Release.key | sudo apt-key add – % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 1358 100 1358 0 0 896 0 0:00:01 0:00:01 --:--:-- 895 OK
我們將在 apt 的源目錄中建立一個儲存庫地址。
$ echo 'deb http://download.owncloud.org/download/repositories/stable/Ubuntu_16.04/ /' | sudo tee /etc/apt/sources.list.d/owncloud.list $ deb http://download.owncloud.org/download/repositories/stable/Ubuntu_16.04/ /
新增新的源後,我們將更新 apt-get 儲存庫並安裝 ownCloud 包。
$ sudo apt-get update Hit:1 http://in.archive.ubuntu.com/ubuntu xenial InRelease Hit:2 http://security.ubuntu.com/ubuntu xenial-security InRelease Hit:3 http://in.archive.ubuntu.com/ubuntu xenial-updates InRelease Ign:4 http://download.owncloud.org/download/repositories/stable/Ubuntu_16.04 In Release Hit:5 http://in.archive.ubuntu.com/ubuntu xenial-backports InRelease Get:6 http://download.owncloud.org/download/repositories/stable/Ubuntu_16.04 Re lease [984 B] Get:7 http://download.owncloud.org/download/repositories/stable/Ubuntu_16.04 Re lease.gpg [481 B] Get:8 http://download.owncloud.org/download/repositories/stable/Ubuntu_16.04 Pa ckages [1,611 B] Fetched 3,076 B in 1s (1,982 B/s) Reading package lists... Done $ sudo apt-get install owncloud
安裝包後,我們需要重新啟動 Apache 伺服器才能使安裝時的更改生效。
$ sudo systemctl restart apache2
為 ownCloud 配置 MySQL 資料庫
我們需要為 ownCloud 建立一個單獨的資料庫,並向 ownCloud 使用者提供訪問許可權。
$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.13-0ubuntu0.16.04.2 (Ubuntu) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> CREATE DATABASE owncloud; Query OK, 1 row affected (0.00 sec) mysql> GRANT ALL ON owncloud.* to 'owncloud'@'localhost' IDENTIFIED BY 'password'; Query OK, 0 rows affected, 1 warning (0.00 sec) Mysql> flush privileges; Mysql> \q
為 ownCloud 建立自己的 SSL 證書
我們將使用 openssl 生成 SSL,並將 SSL 證書儲存在 /etc/ssl 中。以下是為 ownCloud 生成 openssl 證書的命令:
$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt Generating a 2048 bit RSA private key .............................................................................................+++ ..............................................................+++ Writing new private key to '/etc/ssl/private/apache-selfsigned.key' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:IN State or Province Name (full name) [Some-State]:Telengana Locality Name (eg, city) []:Hyderabad Organization Name (eg, company) [Internet Widgits Pty Ltd]:xxxx Organizational Unit Name (eg, section) []:owncloud Common Name (e.g. server FQDN or YOUR name) []:owncloud Email Address []:admin@owncloud.com
為 Owncloud 配置 Apache SSL 虛擬主機檔案
我們將備份 /etc/apache2/sites-available 中的 default-ssl.conf。
$ sudo cp /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-available/default-ssl.conf.bak
$ sudo vi /etc/apache2/sites-available/default-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin owncloud.com
ServerName 192.168.1.117
DocumentRoot /var/www/owncloud
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
</VirtualHost>
</IfModule>完成 SSL 配置後,我們需要重新啟動 apache 以使更改在機器上生效。
$ sudo systemctl restart apache2.service
配置 ownCloud
要配置 ownCloud,我們需要訪問站點 URL,開啟任何瀏覽器並輸入 https://your-IP-Address/owncloud。
在我的例子中是 https://192.168.1.117/owncloud

首先,我們需要為此 ownCloud 建立一個管理員帳戶。
輸入管理員帳戶的使用者名稱和密碼後,我們應該點選下面提到的“儲存和資料庫”:

如果我們想更改客戶端或使用者上傳資料的資料夾,我們可以在此處更改資料庫名稱,我們還需要提供 MySQL 資料庫的使用者名稱和密碼以進行訪問,還需要提供我們在前面步驟中建立的資料庫名稱。
輸入配置後,我們需要點選螢幕末尾的“完成設定”按鈕。

配置完成後,我們會看到一個歡迎啟動畫面。
點選啟動畫面右上角的 X,我們將進入主介面。

點選右上角的“管理員”以設定管理員選項。
點選“個人”以設定管理員的全名,並設定應用程式密碼,該密碼在使用者從裝置使用應用程式訪問 ownCloud 時使用,此密碼將授予訪問 ownCloud 帳戶的許可權。

為 OwnCloud 建立使用者
點選螢幕右上角的“管理員”選項,然後點選“使用者”。

有關更多管理選項,您可以點選右上角的“管理員”,然後點選“管理員”,您將有更多選項來設定和保護您的 ownCloud。

完成此設定和配置後,我們現在就可以在 Ubuntu 16.04 上配置自己的雲了。ownCloud 的主要優點是我們可以保護儲存在我們自己環境中的資訊和資料。我們還可以使用公共 URL 在使用者之間共享內容。
資料結構
網路
關係資料庫管理系統 (RDBMS)
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP