How To Install and Configure ownCloud on Debian 9

Introduction

ownCloud is an open-source file sharing server and collaboration platform that can store your personal content, like documents and pictures, in a centralized location. This allows you to take control of your content and security by not relying on third-party content hosting services like Dropbox.

In this tutorial, we will install and configure an ownCloud instance on a Debian 9 server.

Prerequisites

In order to complete the steps in this guide, you will need the following:

  • A sudo user and firewall on your server: You can create a user with sudo privileges and set up a basic firewall by following the Debian 9 initial server setup guide.
  • A LAMP stack: ownCloud requires a web server, a database, and PHP to function properly. Setting up a LAMP stack (Linux, Apache, MySQL, and PHP) server fulfills all of these requirements. Follow this guide to install and configure this software.
  • An SSL certificate: How you set this up depends on whether or not you have a domain name that resolves to your server.
    • If you have a domain name... the easiest way to secure your site is with Let's Encrypt, which provides free, trusted certificates. Follow the Let's Encrypt guide for Apache to set this up.
    • If you do not have a domain... and you are just using this configuration for testing or personal use, you can use a self-signed certificate instead. This provides the same type of encryption, but without the domain validation. Follow the self-signed SSL guide for Apache to get set up.

Step 1 – Installing ownCloud

The ownCloud server package does not exist within the default repositories for Debian. However, ownCloud maintains a dedicated repository for the distribution that we can add to our server.

To begin, let's install a few components to help us add the ownCloud repositories. The apt-transport-https package allows us to use the deb https:// in our apt sources list to indicate external repositories served over HTTPS:

sudo apt update
sudo apt install curl apt-transport-https

Next, download the ownCloud release key using the curl command and import it with the apt-key utility with the add command:

curl https://download.owncloud.org/download/repositories/production/Debian_9.0/Release.key | sudo apt-key add -

The 'Release.key' file contains a PGP (Pretty Good Privacy) public key which apt will use to verify that the ownCloud package is authentic.

In addition to importing the key, create a file called owncloud.list in the sources.list.d directory for apt. The file will contain the address to the ownCloud repository.

echo 'deb http://download.owncloud.org/download/repositories/production/Debian_9.0/ /' | sudo tee /etc/apt/sources.list.d/owncloud.list

Now, we can use the package manager to find and install ownCloud. Along with the main package, we will also install a few additional PHP libraries that ownCloud uses to add extra functionality. Update your local package index and install everything by typing:

sudo apt update
sudo apt install php-bz2 php-curl php-gd php-imagick php-intl php-mbstring php-xml php-zip owncloud-files

Everything we need is now installed on the server, so next we can finish the configuration and we can begin using the service.

Step 2 — Adjusting the Document Root

The ownCloud package we installed copies the web files to /var/www/owncloud on the server. Currently, the Apache virtual host configuration is set up to serve files out of a different directory. We need to change the DocumentRoot setting in our configuration to point to the new directory.

You find which virtual host files reference your domain name or IP address using the apache2ctl utility with the DUMP_VHOSTS option. Filter the output by your server's domain name or IP address to find which files you need to edit in the next few commands:

sudo apache2ctl -t -D DUMP_VHOSTS | grep server_domain_or_IP

The output will probably look something like this:

Output*:443                  server_domain_or_IP (/etc/apache2/sites-enabled/server_domain_or_IP-le-ssl.conf:2)
         port 80 namevhost server_domain_or_IP (/etc/apache2/sites-enabled/server_domain_or_IP.conf:1)

In the parentheses, you can see each of the files that reference the domain name or IP address we'll use to access ownCloud. These are the files you'll need to edit.

For each match, open the file in a text editor with sudo privileges:

sudo nano /etc/apache2/sites-enabled/server_domain_or_IP.conf

Inside, search for the DocumentRoot directive. Change the line so that it points to the /var/www/ownclouddirectory:

Example DocumentRoot edit

<VirtualHost *:80>
    . . .
    DocumentRoot /var/www/owncloud
    . . .
</VirtualHost>

Save and close the file when you are finished. Complete this process for each of the files that referenced your domain name (or IP address if you did not configure a domain for your server).

When you are finished, check the syntax of your Apache files to make sure there were no detectable typos in your configuration:

sudo apache2ctl configtest

OutputSyntax OK

Depending on your configuration, you may see a warning about setting ServerName globally. As long as the output ends with Syntax OK, you can ignore that warning. If you see additional errors, go back and check the files you just edited for mistakes.

If your syntax check passed, reload the Apache service to activate the new changes:

sudo systemctl reload apache2

Apache should now know how to server your ownCloud files.

Step 3 – Configuring the MySQL Database

Before we move on to the web configuration, we need to set up the database. During the web-based configuration process, we will need to provide an database name, a database username, and a database password so that ownCloud can connect and manage its information within MySQL.

Begin by logging into your database with the MySQL administrative account:

sudo mysql

If you set up password authentication for a MySQL administrative account, you may have to use this syntax instead:

mysql -u admin -p

Create a dedicated database for ownCloud to use. We will name the database owncloud for clarity:

CREATE DATABASE owncloud;

Note: Every MySQL statement must end with a semi-colon (;). Be sure to check that this is present if you are experiencing an issue.

Next, create a separate MySQL user account to manage the newly created database. Creating one-function databases and accounts is a good idea from a management and security standpoint. As with the naming of the database, choose a username that you prefer. We elected to go with the name owncloud in this guide.

GRANT ALL ON owncloud.* to 'owncloud'@'localhost' IDENTIFIED BY 'owncloud_database_password';

Warning: Be sure to put an actual password where the command states: owncloud_database_password

With the user assigned access to the database, perform the flush privileges operation to ensure that the running instance of MySQL knows about the recent privilege assignment:

FLUSH PRIVILEGES;

You can now exit the MySQL session by typing:

exit

With the ownCloud server installed and the database set up, we are ready to turn our attention to configuring the ownCloud application.

Step 4 – Configuring ownCloud

To access the ownCloud web interface, open a web browser and navigate to the following address:

https://server_domain_or_IP

Note: If you are using a self-signed SSL certificate, you will likely be presented with a warning because the certificate is not signed by one of your browser's trusted authorities. This is expected and normal. Click the appropriate button or link to proceed to the ownCloud admin page.

You should see the ownCloud web configuration page in your browser.

Create an admin account by choosing a username and a password. For security purposes it is not recommended to use something like "admin" for the username:

ownCloud Admin Account

Next, leave the Data folder setting as-is and scroll down to the database configuration section.

Fill out the details of the database name, database username, and database password you created in the previous section. If you used the settings from this guide, both the database name and username will be owncloud. Leave the database host as localhost:

ownCloud database configuration

Click the Finish setup button to finish configuring ownCloud using the information you've provided. You will be taken to a login screen where you can sign in using your new account:

ownCloud login screen

On your first login, a screen will appear where you can download applications to sync your files on various devices. You can download and configure these now or do it at a later time. When you are finished, click the x in the top-right corner of the splash screen to access the main interface:

ownCloud Main Interface

Here, you can create or upload files to your personal cloud.

Conclusion

ownCloud can replicate the capabilities of popular third-party cloud storage services. Content can be shared between users or externally with public URLs. The advantage of ownCloud is that the information is stored in a place that you control and manage without a third party.

Explore the interface and for additional functionality, install plugins using ownCloud's app store.

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,258评论 6 498
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,335评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,225评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,126评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,140评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,098评论 1 295
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,018评论 3 417
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,857评论 0 273
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,298评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,518评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,678评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,400评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,993评论 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,638评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,801评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,661评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,558评论 2 352

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,322评论 0 10
  • 排完座位后 我:以后我们按成绩来排位置,第一名想坐哪就坐哪。 学生:就语文成绩吗? 我:语数英三本成绩累计第一的 ...
    Mystery2阅读 310评论 0 0
  • 说到激励,大到公司的管理,小到孩子的教育,人们最容易想到的无非是奖励或者惩罚,这种简单的办法,有用吗?确实有用,但...
    坐怀不乱_d4bd阅读 1,412评论 0 2
  • 分析项目中预览大图片滑动卡顿问题 最近在项目中实现一个较流行的图片预览功能,列表中有多张小图,点击小图时,图片以小...
    wyonxue阅读 2,151评论 0 0
  • Linux print system linux中的调试方法有很多种,但我们最常用的也是最关键的调试工具应该就是使...
    Creator_Ly阅读 1,933评论 0 4