element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi Projects
  • Products
  • Raspberry Pi
  • Raspberry Pi Projects
  • More
  • Cancel
Raspberry Pi Projects
Blog Create your own cloud server on the Raspberry Pi 2
  • Blog
  • Documents
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi Projects to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: DaveYoung
  • Date Created: 5 May 2015 3:40 PM Date Created
  • Views 23017 views
  • Likes 11 likes
  • Comments 30 comments
  • rpibeginner
  • raspberrypi
  • dyoung
  • raspberry_pi_projects
  • server
  • owncloud
  • dropbox
Related
Recommended

Create your own cloud server on the Raspberry Pi 2

DaveYoung
DaveYoung
5 May 2015

A couple years ago, I showed how to setup an ownCloud server on a Raspberry Pi.  The system worked, but there were some performance hiccups. Most importantly was the ability for the system to handle large files and for the Pi v1 to take on the task in a speedy manner. I found myself using Microsoft’s OneDrive more often, electing to use their more proven platform for anything that didn’t require tight privacy controls and a firm handle on my data’s location. Still, it was a small, secure, and low-power cloud storage solution.image

 

With the latest release of the Raspberry Pi 2Raspberry Pi 2, I thought this was a perfect time to update both my hardware and software in hopes of seeing performance improvements. The result gave ownCloud a whole new lease on life, at least in my lab. Check out my video showing the system and its performance:

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

I can’t be sure if it is the upgraded hardware, the updated linux OS and packages, changing to an nginx server, or the latest version of ownCloud, but the system worked much better. I had the server up and running within a few hours, and the web and desktop clients singing minutes after that. But the Pi2’s vastly improved specs have to be part of it:

image

Although things are greatly improved, it still can’t beat the usability of OneDrive. I tried creating issues for the system by uploading a 1GB file from ‘Computer A’ over a browser, uploading music files from ‘Computer B’ via the client, and quickly browsing the files from ‘Computer C’ over a browser. It worked for a while, but it had difficulty on the 1GB file upload and caused a sync error to flag on the client. Thankfully after a few minutes the system figured itself out and updated everything as one would hope. Stability and storage integrity is the ultimate goal so this is yet another example of trading patience/minor hassles for privacy.

image

 

I looked at some customizations like overclocking, but decided against it on account of stability trumping speed when it comes to data storage. Waiting a few seconds or even a minute for a webpage to load or a file to sync is annoying; having the system go down when a critical file is needed is simply unacceptable.

 

The ease of use, extremely low cost, and improved performance makes for a viable system when trying to control data and its privacy. With the new world of cloud-based systems everywhere it’s easy to forget that data is a tangible asset and must be considered as such!

 

While there are a few tutorials out there relating to Pi ownCloud servers, I couldn’t find one that was used with the Pi2 and OwnCloud v8 and solved all of my size limitation issues, so here are the steps that I followed to get the system installed and running.

 

Tutorial:

1. Follow Rpi’s getting started guide to install Raspian

2. Expand filesystem, set international options, Setup hostname and GPU memory split to 16, and enable ssh in the advanced options.

3. Update and upgrade the packages

4. Add users to the www-data group.

sudo usermod -a -G www-data www-data

5. Install nginx , OpenSSL, php5, etc… packages

sudo apt-get install nginx openssl ssl-cert php5-cli php5-sqlite php5-gd php5-common php5-cgi sqlite3 php-pear php-apc curl libapr1 libtool curl libcurl4-openssl-dev php-xml-parser php5 php5-dev php5-gd php5-fpm memcached php5-memcache varnish

6. Create the SSL certificate based on your location, organization, and email by running:

sudo openssl req $@ -new -x509 -days 730 -nodes -out /etc/nginx/cert.pem -keyout /etc/nginx/cert.key

7. Modify the privileges to the two cert files:

sudo chmod 600 /etc/nginx/cert.pem
sudo chmod 600 /etc/nginx/cert.key

   

8. Access the web server configuration file by running the command

sudo nano /etc/nginx/sites-available/default

9. Replace everything in the file with the following, replacing my Pi’s IP (10.0.0.124) with your own (I only put my Pi’s local IP here for security – you may have a global IP to allow you to access it anywhere on the 'net).

upstream php-handler {

server 127.0.0.1:9000;

#server unix:/var/run/php5-fpm.sock;

}

 

server {

listen 80;

server_name 10.0.0.124;

return 301 https://$server_name$request_uri;  # enforce https

}

 

server {

listen 443 ssl;

server_name 10.0.0.124;

 

ssl_certificate /etc/nginx/cert.pem;

ssl_certificate_key /etc/nginx/cert.key;

 

# Path to the root of your installation

root /var/www/owncloud;

 

client_max_body_size 2000M; # set max upload size

fastcgi_buffers 64 4K;

 

rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;

rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;

rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;

 

index index.php;

error_page 403 /core/templates/403.php;

error_page 404 /core/templates/404.php;

 

location = /robots.txt {

allow all;

log_not_found off;

access_log off;

}

 

location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README) {

deny all;

}

 

location / {

                # The following 2 rules are only needed with webfinger

                rewrite ^/.well-known/host-meta /public.php?service=host-meta last;

                rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;

 

                rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;

                rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;

 

                rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;

 

                try_files $uri $uri/ index.php;

}

 

location ~ \.php(?:$|/) {

                fastcgi_split_path_info ^(.+\.php)(/.+)$;

                include fastcgi_params;

                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

                fastcgi_param PATH_INFO $fastcgi_path_info;

                fastcgi_param HTTPS on;

                fastcgi_pass php-handler;

}

 

# Optional: set long EXPIRES header on static assets

location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {

                expires 30d;

                # Optional: Don't log access to assets

                access_log off;

}

 

}

   

10. Edit php.ini file to allow 2GB file sizes by running the following and changing a couple parameters:

sudo nano /etc/php5/fpm/php.ini

search for upload_max_filesize and set it to 2000M

search for post_max_size and set it to 2000M

   

11. Configure PHP settings by running the following two commands and making the described changes in each file:

sudo nano /etc/php5/fpm/pool.d/www.conf

Then Change:

listen = /var/run/php5-fpm.sock
to :
listen = 127.0.0.1:9000

   

sudo nano /etc/dphys-swapfile

Then Change:

CONF_SWAPSIZE=100
to :
CONF_SWAPSIZE=512

   

12. Restart the Pi

13. Install owncloud by running the following commands and verify the files are in the right place:

sudo mkdir -p /var/www/owncloud

sudo wget https://download.owncloud.org/community/owncloud-8.0.2.tar.bz2

sudo tar xvf owncloud-8.0.2.tar.bz2

sudo mv owncloud/ /var/www/

sudo chown -R www-data:www-data /var/www

rm -rf owncloud owncloud-8.0.2.tar.bz2

   

14. Plug in the external hard drive (mine was formatted with NTFS).

15. Install the package to work with NTFS if your drive is setup as NTFS

sudo apt-get install ntfs-3g

   

16. Make a directory for mounting the drive

sudo mkdir /media/owncloud

   

17. Mount the drive (command below for NTFS drive)

sudo mount -t ntfs-3g -o uid=1000,gid=1000,umask=007 /dev/sda1 /media/owncloud

18. Find the UUID by running the following command. UUIS is the blue text associated with the sda1 drive that will look something like 4264E66D64E66361

ls -l /dev/disk/by-uuid/

   

19. Backup and then open fstab by running:

sudo cp /etc/fstab /etc/fstab.backup
sudo nano /etc/fstab

   

20. Edit fstab by adding the following at the bottom while replacing my UUID 4264E66D64E66361 with the one you found on your setup in step 18:

UUID=4264E66D64E66361 /media/owncloud ntfs-3g uid=1000,gid=1000,umask=007 0 0

   

21. Reboot the Pi and check that your drive has been automatically mounted.

22. Set permissions for the www-data group:

sudo usermod -a -G pi www-data

23. Navigate to cd /var/www/owncloud

24. Edit the .htaccess file to set the max file size:

sudo nano .htaccess

Then set the following values to 2000M:

Php_value upload_max_filesize

Php_value post_max_size

Php_value memory_limit

   

25. Edit the .user.ini file and change the following fields to 2000M:

sudo nano .user.ini

Then set the following values to 2000M:

upload_max_filesize

post_max_size

memory_limit

   

26. Reboot the Pi.

27. Visit the location of your Pi’s IP (mine was 10.0.0.124) with a browser to access your ownCloud Server and create an admin account! Note that without cURL installed, there may be an error for files over 4GB. But since this setup limits the files to 2GB, that’s no big deal.

28. Install ownCloud's free client/app on any of your machines, or elect you just use the browser interface.

29. Implement your favorite method of allowing access to your Pi2 from the internet. These steps vary from network to network and modem to modem, but here are a few resources that may help:

  • Log into your router and forward port 22 to the Pi’s IP
  • Configure the pi to accept port forwarding from step 3 of https://forum.owncloud.org/viewtopic.php?f=8&t=18742
  • Check out No-ip.com which is a service that would help if the above doesn't work for you

NOTE: A comment from Nick Vee below that may be helpful to some users:

it was not pointing to the USB drive. The data was going on the sd card. There are a few steps missing to make sure the USB drive is being used. Make sure in /var/owncloud/config/config.php that the data directory is pointing to your USB mount point for your external disk. There is supposed to be a dialog for this in the admin setup, but I never saw it.  Also the data directory on your USB must be owned by www-data (the web server user) so you have to set that permission with a chown command. There are examples of this in "how to move your data directory" in the owncloud forums.

Of course being an analog electronics guy, I am no linux wiz. I was able to put together this tutorial which is a variation of the following resources published by the real pros:

http://www.techjawab.com/2014/08/how-to-setup-owncloud-7-on-raspberry-pi.html

https://blog.adafruit.com/2014/11/21/12-easy-steps-to-install-owncloud-7-0-3-on-raspberry-pi-raspberry_pi-piday-raspberrypi/

https://forum.owncloud.org/viewtopic.php?f=8&t=26005

https://github.com/petrockblog/OwncloudPie

https://forum.owncloud.org/viewtopic.php?f=8&t=18742

  • Sign in to reply

Top Comments

  • Former Member
    Former Member over 10 years ago +1
    thx for the guide. But if I want to use from the internet I had to modify /var/www/owncloud/config/config/php and I had to add the dyndns name. Otherwise I got an unknown error in the android ownloud app…
  • Former Member
    Former Member over 10 years ago +1
    Thanks for this tutorial, Dave. It can be a challenge for us non Linix types to get this stuff working. A couple of more comments having gone thru the whole thing and gotten it working: 1, Minor nit: …
  • Former Member
    Former Member over 10 years ago +1
    Fantastic tutorial - just completed it with a RPI3 (arrived this morning) and it all went very smooth. Thanks! I had to use php5-curl, and used /dev/sda1 instead of my UUID. I'm running Ubuntu-Mate (15x…
  • Former Member
    Former Member over 10 years ago

    anybody got this to work with a no-ip dynamic dns?

    i can access if i use the ip address and port forward a random 5 digit external and 443 internal: https://xxx.xxx.xxx:xxxxxx but this ip is subject to change, hence the need for no-ip

     

    it will not work if i use https://my-domain-name.net

    if i enter the domain my-domain-name.net without https i get an error 400 saying http is being sent to a https port, and the ip address becomes displayed in the address bar

    if i enter https://my-domain-name.net/ or https://www.my-domain-name.net/ the browser just hangs and eventually says the server is not responding.

     

    i set up the no-ip client and noip2 -S shows that my domains are configured to the correct ip address.

    i have 4 hosts configured:

    host -.my-domain-name.net

    host ftp.my-domain-name.net

    host mail.my-domain-name.net

    host www.my-domain-name.net

     

    how should nginx be set up so that https://my-domain-name.net/ will redirect to the owncloud?

    thanks

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to Former Member

    not sure of the cause of this but i got 8.2.2 working after i got the same messages by installing php5-curl.

     

    sudo apt-get update && sudo apt-get install php5-curl

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 10 years ago

    I just went through the tutorial a couple of times, installing version 8.2.1 instead of the mentioned 8.0.2.  I actually went through the process 3 times, one time screwing everything up with some accidental commands.  Both of the times I got through the installation, it came up with this error message:

    PHP module cURL not installed.

    Please ask your server administrator to install the module.

     

    PHP modules have been installed, but they are still listed as missing?

    Please ask your server administrator to restart the web server.

    I just went back and followed all the ownCloud installation instructions from this tutorial using version 8.0.2 and it seems to work fine.  What could the problem be with version 8.2.1?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 10 years ago

    Just copied my comment on G+ to the blog:

    Nice tutorial, one point seems missing: Mention how to backup the database automatically. I had owncloud installed and tested and always was thinking "Make a sql backup script." but never done it (and learned it the hard way).

     

    Now I run a script with cron every night:

     

    mysqldump --defaults-extra-file=/etc/sqldump.cf DBNAME | gzip > "/mnt/ext/backup/$(date '+%F').sql.gz"

    find /mnt/ext/backup -type f -mtime +7 -exec rm {} \;

     

    The script just makes an sqldump, gzip compresses it and writes it to a pendrive. Then it searches for backups older than 7 days an deletes them.

    SQL-User and Password are defined in the /etc/sqldump.cf (readable only for the user running the script) file so SQL password and user don't show up if someone uses ps at the machine.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to Former Member

    As far as I know, they both serve slightly different purposes. But I'm no expert either, so I'm happy to be corrected.

     

    Samba or an NFS share will make your raspberry pi basically a NAS for your local network. You can use these shares as a network drive in your OS of choice. Personally, I use this for video/audio storage so I can access them with every device, e.g. another raspberry with Kodi on it, in my home network.

     

    OwnCloud will give you the opportunity to access your storage with a browser and/or WebDAV, share your contacts and calendars (CardDAV, CalDAV) to your devices and much more. You even can share network shares in your local network with ownCloud, you will need samba installed off course.

     

    If you need windows network shares in your home network, you will need to run samba. If you want to access your data via http(s) and/or sync your contacts and calendars you will need OwnCloud (or something similar).

     

    Further more:

    If you only want to access your stored data at home if you are out you can also use ssl/scp software ore use a VPN to tunnel to your home network. The first one is quite easy as the ssl-server is usually running, you only have to open you raspberry to the public (DynDNA, NoIP) and forward the port 22. Of course, you will need to make sure your ssl-server is correctly configured and up to date.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
<>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube