How to install and configure ownCloud 10 on Raspberry Pi?

Raspberry Pi is a low-cost and compact single-board computer as small as size of your palm. Though not powerful enough to perform complex jobs, it is still capable of serving purposes of academic study, hobbyist interest, and very light-weight multi-purpose server.

Previously, we just finished installing Raspbian on Raspberry Pi 3.0. Today, we will continue installing ownCloud 10. With minimum effort and cost, we are able to host our own cloud server on a Raspberry Pi and thus provides ourselves various services, such as mail, CalDav, CardDAV, FTP, streaming and etc.

#1. On Raspbian’s terminal, type

sudo apt update
sudo apt upgrade

apt update / apt upgrade

to make sure everything is up to date on operating system itself:

#2. On Raspbian’s terminal, type

sudo apt install apache2 -y

to install Apache.

Install Apache

#3. On Raspbian’s terminal, type

wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt-get update

to update sources list.

Update source

#4. On raspbian’s terminal, type the next 4 lines of commands to install additiaonl packages:

sudo apt install -y apache2 mariadb-server libapache2-mod-php7.2
sudo apt install -y php7.2-gd php7.2-json php7.2-mysql php7.2-curl
sudo apt install -y php7.2-intl php7.0-mcrypt php-imagick
sudo apt install -y php7.2-zip php7.2-xml php7.2-mbstring

Install package 1/4
Install package 2/4
Install package 3/4
Install package 4/4

#5. On Raspbian terminal, download ownCloud 10.1.0 in a temp folder and extract it in the temp folder.

cd /tmp
wget https://download.owncloud.org/community/owncloud-10.1.0.tar.bz2
tar -xvf owncloud-10.1.0.tar.bz2

Download and extract ownCloud 10.1.0

#5. On Raspbian terminal, change owner and group to which the extracted owncloud folder belongs. Then, move owncloud folder to /var/www/.

cd /tmp
sudo chown -R www-data:www-data owncloud
sudo mv owncloud /var/www/

Change folder ownership and move to www folder

#6. On Raspbian terminal, create a configuration file, owncloud.conf in /etc/apache2/sites-available/ folder

sudo nano /etc/apache2/sites-available/owncloud.conf

Edit conf file with nano tool

The following example of conf file contains basic website configuration and vhost information:

Alias /owncloud "/var/www/owncloud/"
<Directory /var/www/owncloud/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav on
</IfModule>
SetEnv HOME /var/www/owncloud
SeEnv HTTP_HOME /var/www/owncloud
</Directory>
<VirtualHost *:80>
ServerName owncloud10.ddns.net
ServerAdmin webmaster@localhost
DocumentRoot /var/www/owncloud/
</VirtualHost>

Edit conf file

#7. If 000-default.conf exists in /etc/apache2/sites-available and /etc/apache2/sites-enabled, then use mv command to move them somewhere for backup.

sudo mv 000-default.conf /home/pi/Desktop
sudo mv 000-default.conf /home/pi/Desktop

#8. On Raspbian terminal, create symbolic link from /etc/apache2/sites-available/owncloud.conf to /etc/apache2/sites-enabled/owncloud.conf.

sudo ln -s /etc/apache2/sites-available/owncloud.conf /etc/apache2/sites-enabled/owncloud.conf
sudo a2enmod headers
sudo systemctl restart apache2
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime

Add symbolic link to conf file and enable additional parameters

#9. On Raspbian terminal, create ownCloud database in MySQL following commands below:

sudo mysql -u root -p

Enter password. Use user Pi‘s password that was set when installing Raspbian at the beginning.

create user owncloud@localhost identified by '12345';
grant all privileges on owncloud.* to owncloud@localhost identified by '12345';
flush privileges;
exit;

Create ownCloud database in MySQL

#10. Open a web browser and try opening ownCloud’s login screen by typing http://127.0.0.1. Create a username and a password for administrator. Keep Data folder intact. For database:

Username: owncloud
Password: 12345
Database: owncloud
Server: localhost

Set username, password, database password, data username, password and database

#11. Then, we will log in as administrator for the first time.

#12. On Raspbian terminal, we will install and configure phpmyadmin for ownCloud database.

sudo apt install phpmyadmin -y
Select apache2
Yes for "Configure database for phpmyadmin with dbconfig-common?"
Enter MySQL application password for phpmyadmin
Confirm password

Install phpmyadmin
Select apache2
Configure database for phpmyadmin with dbconfig-common
Create MySQL application password
Confirm password
Phpmyadmin installation complete

#13. Before configuring SSL for Apache, make sure to enable a2enmod_ssl.

sudo a2enmod ssl

a2enmod ssl

#14. Use OpenSSL command to create SSL certificate and key in a pre-created folder /etc/apache2/ssl.

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/owncloud10.ddns.net.key -out /etc/apache2/ssl/owncloud10.ddns.net.crt

Create SSL certificate for owncloud10.ddns.net

#15. Open etc/apache2/sites-available/default-ssl.conf and make some changes:

ServerAdmin webmaster@localhost
ServerName owncloud10.ddns.net:443 <-- enter server host name
DocumentRoot /var/www/owncloud <-- swap html with owncloud
.
.
SSLEngine on <-- change from off to on
.
.
SSLCertificatefile /etc/apache2/ssl/owncloud10.ddns.net.crt
SSLCertificateKeyFile /etc/apache2/ssl/owncloud10.ddns.net.key
(path to store SSL certificate and key file)

Modify default_ssl.conf file

Note: In case of the need for a real CA-signed certificate, get it from such certificate vendor, such as Ksoftware. Or, there is some free SSL certificate website like LetsEncrypt. One more line has to be edited for adding ca-bundle certificate:

SSLCertificateChainFile   /etc/apache2/ssl/owncloud10.ddns.net.ca-bundle.crt

add ca-bundle certificate at the bottom

#16. Before enabling SSL for Apache, make sure to enable a2ensite_ssl on Raspbian terminal.

sudo a2ensite default-ssl

a2ensite default-ssl.conf

#17. On Raspbian terminal, enter the following command to restart Apache service.

sudo service apache2 restart

Restart Apache service

#18. In order to access ownCloud server from outside of local network, add the server’s host name and/or its public IP to trusted domain within owncloud’s config.php.

0 => '127.0.0.1',
1 => 'owncloud10.ddns.net',

Add ownCloud server’s host name/public IP into trusted domain

#19. One last stop, in case server is running behind a router, make sure to add port 80 and 443 in Port Forwarding assignment list pointing to ownCloud server host’s LAN IP.

This article looks like a long one, but the whole process of ownCloud server installation actually takes less than an hour. After the server is built, we can use lots of service features, such as mail, address book, calendar, task and others. Our next chapter will be configuring mail server, CalDAV and CardDAV servers for your reference.

One more thing, after building an ownCloud server, we can benefit from this ownCloud server for syncing contacts, calendar and tasks wherever we go. However, there is something missing: messaging service. For some of you, who are familiar with Linux, hmail server is good option and it is free. If you are more familiar with Windows and like to build a mail server within a few steps, I would recommend EVO Mail Server. All you need to do is configuring DNS recoreds on DNS hosting service as well as entering domain name and creating mail accounts in EVO Mail Server’s UI. Yet, there are still lots of optional features such as DKIM, DMARC, SSL certificate, antispam filters, white/black list and so on to be calibarted. Here is a know-how on installing and configuring EVO Mail Server.

Leave a Reply