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
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.
#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.
#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
#5. On Raspbian terminal, download ownCloud 10.1.0 in a temp folder and extract it in the temp folder.
tar -xvf owncloud-10.1.0.tar.bz2
#5. On Raspbian terminal, change owner and group to which the extracted owncloud folder belongs. Then, move owncloud folder to /var/www/.
sudo chown -R www-data:www-data owncloud
sudo mv owncloud /var/www/
#6. On Raspbian terminal, create a configuration file, owncloud.conf in /etc/apache2/sites-available/ folder
sudo nano /etc/apache2/sites-available/owncloud.conf
The following example of conf file contains basic website configuration and vhost information:
Alias /owncloud "/var/www/owncloud/"
SetEnv HOME /var/www/owncloud
SeEnv HTTP_HOME /var/www/owncloud
#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
#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';
#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:
#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
Yes for "Configure database for phpmyadmin with dbconfig-common?"
Enter MySQL application password for phpmyadmin
#13. Before configuring SSL for Apache, make sure to enable a2enmod_ssl.
sudo 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
#15. Open etc/apache2/sites-available/default-ssl.conf and make some changes:
ServerName owncloud10.ddns.net:443 <-- enter server host name
DocumentRoot /var/www/owncloud <-- swap html with owncloud
SSLEngine on <-- change from off to on
(path to store SSL certificate and key 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:
#16. Before enabling SSL for Apache, make sure to enable a2ensite_ssl on Raspbian terminal.
sudo a2ensite default-ssl
#17. On Raspbian terminal, enter the following command to restart Apache service.
sudo service apache2 restart
#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',
#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.