News

Raspberry Pi private cloud

Turn the Pi into your own personal Dropbox using ownCloud and an internet connection

Setup a Pi-vate cloud. Get it? Yeah, sorry, we'll stop.

The themes of a lot of our Raspberry Pi guides revolve around the size and portability of the Pi itself, lending it to tasks you may have used a full-sized or small computer for in the past that the Pi can now take over. Having your own private cloud is another excellent use of the Raspberry Pi’s capabilities, because you can store it hidden away somewhere and it will require very little day- to-day maintenance.

Make sure you invest in some decent, portable USB storage such as an external HDD, and also get a case for your Pi in the process.

Setup a Pi-vate cloud. Get it? Yeah, sorry, we'll stop.
Setup a Pi-vate cloud. Get it? Yeah, sorry, we’ll stop.

What you’ll need

External storage
Constant internet connection

Step-by-step

Step 01 Set a static IP

After setting up your wired or wireless internet connection, you need to make it static. Use sudo nano /etc/network/interfaces to open up the network settings file. Fine the iface eth0 line so you can change and add to it:

iface eth0 inet static
   address 192.168.0.50
   gateway 192.168.0.1
   netmask 255.255.255.0
   network 192.168.0.0
   broadcast 192.168.0.255

Step 02 Install a lot of software

You’ll want Apache software and PHP for this. Install everything you need with:

$ sudo apt-get install apache2 php5 php5-json php5-gd php5-sqlite curl libcurl3 libcurl4-openssl-dev php5- curl php5-gd php5-cgi php-pear php5-dev build- essential libpcre3-dev libapache2-mod-php5 php-apc

Step 03 Setup PHP accelerator

Install your accelerator with sudo pecl install apc and create an ini file for it. To do this, use sudo nano/etc/php5/cgi/conf.d/apc.ini and then add this to the file:

extension=apc.so
apc.enabled=1
apc.shm_size=30

Step 04 Configure file limits

Go into the Apache config file with sudo nano /etc/php5/apache2/php.ini. It’s a big file, but there are two filesize options you need to find, and a third extension option you need to add as below:

upload_max_filesize = 2048M
post_max_size = 2200M
extension = apc.so

Step 05 Set up SSL

First of all, you need to enable SSL in Apache; do this by using sudo nano /etc/apache2/sites-enabled/000-default and change ‘None’ to ‘All’ in the AllowOverride option. Follow this up with the following two commands:

$ sudo a2enmod rewrite
$ sudo a2enmod headers

Step 06 Finish up with Apache

You now need to do two sets of commands: a big one which requires some info and then a restart:

$ sudo openssl genrsa -des3 -out server.key 1024
$ sudo openssl rsa -in server.key -out server.key. insecure
$ sudo openssl req -new -key server.key -out server.csr $ sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
$ sudo cp server.crt /etc/ssl/certs;sudo cp server.key /etc/ssl/private;sudo a2enmod ssl
$ sudo a2ensite default-ssl
$ sudo service apache2 restart

Step 07 Download and install ownCloud

Here you have a series of commands to run that will download, unzip and install ownCloud to the right place:

$ wget https://download.owncloud.org/community/ owncloud-7.0.0.tar.bz2
$ sudo tar -xjf owncloud-7.0.0.tar.bz2
$ sudo cp -r owncloud /var/www

Step 08 ownCloud permissions

Make sure your hard drive is connected and mounted as you want it. First, give webserver permission to use ownCloud:

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

Next, use sudo nano /var/www/owncloud/.htaccess and make the same changes you did in the php.ini file above. Finally, give permissions to the location you mounted the hard drive to with:

$ sudo chown -R www-data:www-data [mount]

Step 09 Set up ownCloud

Open Midori and navigate to https://[ipaddress]/owncloud to begin the ownCloud setup process. The first thing you’ll need to do is change the data location to the mount point of your external drive, which can be found in the advanced options.

×