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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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 19256 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 9 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 9 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 9 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 8 years ago

    Hi

    Can I transfer photo,voice , using rassbrery pi to a cloud server  ?

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

    Great job! This toutorial worked great for me!

     

    I don't know if you are still maintaining this, but a new version of owncloud has come out and you have to update your urls in your curl command.

     

    Also, if anyone else if having problems with a gateway timout error, I used this guide and it seems to have fixed it for me: https://easyengine.io/tutorials/php/increase-script-execution-time/

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

    Hi Victor,

     

    When you say 2GB in total, do you mean the hard-drive space that OwnCloud can use? By default, OwnCloud uses the /var/www/OwnCloud directory, which is likely on your root drive.

     

    If you have mounted your 500GB drive, you can see it by running the command 'df -h', as I show below:

     

    james@cloud:~$ df -h

    Filesystem      Size  Used Avail Use% Mounted on

    /dev/root        29G  3.4G   26G  12% /

    devtmpfs        459M     0  459M   0% /dev

    tmpfs           463M     0  463M   0% /dev/shm

    tmpfs           463M   24M  439M   6% /run

    tmpfs           5.0M  4.0K  5.0M   1% /run/lock

    tmpfs           463M     0  463M   0% /sys/fs/cgroup

    /dev/mmcblk0p1   64M   20M   45M  32% /boot

    /dev/sda1       932G  7.1G  925G   1% /media/owncloud

    tmpfs            93M     0   93M   0% /run/user/1000

     

    Here you can see in bold are my two drives, /dev/root is my 32GB SD card (formatted it has 29G usable) and /dev/sda1, which is my 1TB drive, mounted to /media/owncloud

     

    When you install OwnCloud, there is a process to set the data directory to something other than the default, its not neat and tidy to move an installation, but it's doable.

     

    Follow this: https://forum.owncloud.org/viewtopic.php?t=7118

     

    Hope that helps. If you need assistance mounting your drive (and making sure it stays mounted), let me know.

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

    Good afternoon, I need help ...

    I already have my owncloud running on Raspberry successfully PI2, but I am faced with the following:

    I can only get 2 Gigas in total, even as administrator owncloud.

    I have a HD with 500G, how can I change the situation so you can use the HD completely, or put anything you want in owncloud?

     

     

    Thank you in advance

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

    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 Ubuntu with aptitude!) and it's running perfectly. Thanks for the great work.

     

    I'm using owncloud 8.2.2 btw.

     

    The ssl cert seemed to work, but Chrome still says it's nasty. Anyway, something to work on image

    • Cancel
    • Vote Up +1 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 © 2025 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