Our goal is to install ownCloud 10 on the Raspberry pi with Raspbian Stretch installed. We are not just installing ownCloud but also mounting an external drive for lager capacity of data storage and to be able to access it from anywhere in the world with internet access.
This tutorial assumes that you have a fully functional Raspberry pi-2 or 3 with Raspbian installed and a 8 GB Micro SD card Minimum!. If you haven’t installed Raspbian then check out my guide on how to install Raspbian via NOOBS.
There are many ways to install ownCloud onto a Raspberry Pi. This particular tutorial I’ll be downloading and installing the following software / packages we will be using to setup ownCloud 10:
Steps to install ownCloud 10 on the Raspberry pi with Raspbian Stretch:
- Update Raspberry pi System
- Install LAMP Server
- Install ownCloud dependencies
- Install Owncloud 10
- Mount an External Hard drive for larger storage capacity
- Enable SSL for secure access
- Owncloud configuration via web browser
If you don’t have a Raspberry PI I would personally recommend buying the Raspberry pi-3 kit with a 32 GB Micro SD card so that you don’t have to mount an external drive. unless you want to store more than 32GB of data.
Setting up Raspberry Pi for Owncloud 10 Server
1. Turn on the Raspberry Pi. From the terminal or SSH enter the following command:
The following changes needs to be made in the Raspberry Pi configuration
a. Expand the root filesystem to have enough space for the cloud
Select “Advanced Options” –> “Expand Filesystem” (if available)
b. Change user password
“For Security when accessing form the WAN”
c. Change locale to en_US.UTF8
Select “Localisation Options” –> “Change Locale”
d. Memory split, allocate 16M to video graphics
Select “Advanced Options” –> “Memory Split”
e. Overclock to Modest or Medium
Select “Overclock” (if available)
Then Finish, and auto reboot. Upon re-boot you would need to update the RPI and its packages.
Update the Raspberry Pi and its packages
apt update && apt upgrade
Now we need to install and configure LAMP Server.
Install LAMP Server
Open Terminal or simply ssh to the Raspberry pi.
Install Apache web server
apt install apache2 -y
Start and enable Apache on boot
systemctl start apache2 systemctl enable apache2
Install the required packages:
We need to install additional packages required by Owncloud Server
apt install -y apache2 mariadb-server libapache2-mod-php7.0 \ php7.0-gd php7.0-json php7.0-mysql php7.0-curl \ php7.0-intl php7.0-mcrypt php-imagick \ php7.0-zip php7.0-xml php7.0-mbstring
Download Owncloud 10 package:
cd /tmp wget https://download.owncloud.org/community/owncloud-10.0.10.tar.bz2
Extract Owncloud and change the permission
tar -xvf owncloud-10.0.10.tar.bz2 chown -R www-data:www-data owncloud
It will produce a new directory called owncloud. We need to move this directory to /var/www/html/ directory
mv owncloud /var/www/html/
Exit /tmp directory.
Configure Apache Web Server
Create a new configuration file under /etc/apache2/sites-available
sudo nano /etc/apache2/sites-available/owncloud.conf
And then paste these lines and save it
Alias /owncloud "/var/www/html/owncloud/" <Directory /var/www/html/owncloud/> Options +FollowSymlinks AllowOverride All <IfModule mod_dav.c> Dav off </IfModule> SetEnv HOME /var/www/html/owncloud SetEnv HTTP_HOME /var/www/html/owncloud </Directory>
Create Symbolic link
ln -s /etc/apache2/sites-available/owncloud.conf /etc/apache2/sites-enabled/owncloud.conf
Additional apache configuration
Execute these commands to enable some modules
a2enmod headers systemctl restart apache2 a2enmod env a2enmod dir a2enmod mime
Create a MySQL database and user:
mysql -u root -p
You’ll be prompted to enter the Pi User password. Then execute the underneath commands in blue:
MariaDB [(none)]> create database owncloud; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> create user owncloud@localhost identified by '12345'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> grant all privileges on owncloud.* to owncloud@localhost identified by '12345'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> exit; Bye
Configure Owncloud via web browser
If you’re mounting and external hard drive for additional storage capacity skip this step and continue to Mounting and Setting up an external hard drive underneath.
If you are NOT mounting and external hard drive proceed to open the web browser and type the following address:
Change the IP address in blue to your Raspberry pi IP address. You will see the following Owncloud configuration window:
Here enter a username and password to create an admin account then immediately underneath enter your MySQL details as follow:
Click on ‘Finish Setup’ button. That’s it. We’re good to go. Owncloud 10 installed on Raspbian Stretch is now ready for use.
Mounting and Setting up an external hard drive
These instructions are for mounting an NTFS formatted hard drive and allowing ownCloud to store files onto it. Now would be a good time to plug in the external Hard Drive to the RPI.
1. Having an NTFS drive we will need to install a NFTS package by entering the following:
sudo apt-get install ntfs-3g -y
2. Make a directory we can mount to:
sudo mkdir /media/ownclouddrive
3. Create and add the www-data user to the www-data group:
sudo groupadd www-data sudo usermod -a -G www-data www-data
4. Make the user www-data owner of the mounted drive and make its permissions read, write and execute:
sudo chown -R www-data:www-data /media/ownclouddrive sudo chmod -R 775 /media/ownclouddrive
5. Now we need to get the gid, uid and the uuid as we will need to use them so the pi will remember it even if we plug it into a different USB port. Enter the following command for the gid:
id -g www-data
6. Now to get the uid enter the following command:
id -u www-data
7. Also we meed to get the UUID of the attached external hard drive so the Pi can remember this drive even if you plug it into a different USB port.
ls -l /dev/disk/by-uuid
8. Then copy the light blue letters and numbers of the sda1 entry usually located on the bottom. Should look something like (numbers&letters -> ../../sda1). See picture below:
9. Now add your drive into the fstab file so it’ll boot with the proper permissions.
sudo nano /etc/fstab
10. Add the following line to the bottom of the file, updating uid, guid and the UUID with the values we got above. (It should all be a single line). Dont forget to replace the UUID number to yours in stead of the one you copied from here.
UUID=F6941E59941E1D25 /media/ownclouddrive auto nofail,uid=33,gid=33,umask=0027,dmask=0027,noatime 0 0
11. Reboot the Raspberry Pi:
12. Now the drives should automatically be mounted. If mounted we’re all good to go. To check it enter:
sudo ls /media/ownclouddrive
If there are files inside the drive you should be able to see them here. If it’s an empty drive you might not see anything so don’t be surprise if nothing shows up.
If you want to be absolutely positive that the drive is properly mounted, unplug the drive from the RPI plug it onto a PC since the drive is formatted “NTFS” it should be easily detected by the PC, open it, create an txt file name it test, then eject it and plug it back to the RPI and run the following command:
sudo ls /media/ownclouddrive
The txt file you created should be there.
Basic First Access Setup
1. Open your browser and enter the IP address provided, in my case is 192.168.1.140/0wncloud you’ll be directed to your ownCloud storage server.
2. You should be presented with a simple setup screen, Here enter a username and password to create an admin account.
3. Click on Storage & database dropdown and enter your external hard drive directory: /media/ownclouddrive (Skip this if you didn’t setup an external drive).
4. Immediately underneath enter your MySQL details as follow:
5. Click on ‘Finish Setup’ button. That’s it. We’re good to go. Owncloud 10 installed on Raspbian Stretch is now ready for use.
Done! !! all is left is to configure your devices to access your ownCloud storage.
To allow devices like your phone or tablet to access your cloud from anywhere in the world with internet access you must enable SSL then enable port forward:
Log into your router and get the WAN IP address:
Or Google what is my IP address?
Now we need to add the WAN IP to your trusted IP list and not to be overwritten by ownCloud. To do this open the Owncloud config file, enter:
sudo nano /var/www/html/owncloud/config/config.php
Here add the WAN IP (External IP address) you just got from the router or Google to the trusted domains array. Your new entry should look something like this:
1 => 'xxx.xxx.xxx.xxx',
X are just placeholders. Replace the X’s with the WAN IP Address.
Now update the URL of the overwrite.cli.url line with your WAN IP Address. It should look something like this:
'overwrite.cli.url' => 'https://xxx.xxx.xxx.xxx/owncloud',
Here is an example of the completed config.txt file.
Once done save and exit the the config.php.
Now log into your router and navigate to the port forward section.
Port forward SSL port 443 to the Raspberry pi internal IP (LAN IP) address and save settings.
Now your RPI ownCloud is ready to be accessed externally (WAN) and from your devices just download the ownCloud App and enter: “https:// WAN IP Address” on the address bar or devices. below is an example: