Install ownCloud on Raspbian and Raspberry Pi

Raspberry Pi logo

You probably know that I'm fan of ownCloud and Raspberry Pi. So my project was to replace Dropbox with ownCloud using personal server.

Here we will see the whole procedure of installing Raspbian and then ownCloud on Raspberry Pi.

I used:
1. Raspberry Pi
2. Ethernet Cable
3. USB micro plugged on Router
4. 16GB SD card


1. Download Raspbian. You can visit Raspberry Pi download page or you can download direct (this can be changed). Then unzip it.

2. Install Raspbian and update it.
- Find the SD card:
df -h
or better

cat /proc/partitions
eg it's /dev/sdb1.
- Unmount the SD
umount /dev/sdb1
- Copy the image to your SD (don't forget to add sudo before):
sudo dd if=2012-12-16-wheezy-raspbian.img of=/dev/sdb bs=1M;sync
You're all set. Don't forget the user-pass:
user: pi pass: raspberry

3. Boot your Raspberry Pi

You should proceed with update (you can login using ssh with the command ssh root@RASPBERRY's IP):
sudo apt-get update && apt-get dist-upgrade
If you want to get rid of the GUI (since you will use only terminal), follow the steps (as described here):
sudo apt-get update
# Remove libx11-6 to remove x11 and all dependent packages (anything GUI related, basically)

sudo apt-get remove libx11-6 libgtk-3-common xkb-data lxde-icon-theme raspberrypi-artwork penguinspuzzle

# Clean up redundant packages sudo apt-get autoremove
# Purge config files for removed packages

sudo su dpkg -l | awk '/^rc/ {print $2}' | xargs dpkg --purge

Also if you want to set the memory usage so that there is only bare minimum used for the graphics, you need to copy the required memory split file to start.elf, eg. arm240_start.elf would give you 240MB RAM with 16MB for the GPU.

4. Next step, set static IP (as described here). Normally, if you plug once your Raspberry Pi, the IP doesn't change. The problem is when you have your router restarted. Here what you have to change:
- Edit the file /etc/network/interfaces
sudo nano /etc/network/interfaces
- Find the line and change it:
auto eth0
iface eth0 inet static
Use IP, near the end of the DHCP IPs that the router provide you.
To save, press Ctrl+X key on keyboard and then ‘Y’ Enter to exit the text editor.

5. If you want to have access from outside, you should have a router with Dynamic DNS for example Check what your router for that. You'll also need to forward your external IP to your Raspi's IP address on your LAN (step 4). It depends on your router. Usually there's NAT, or Virtual server or Port forward. Use the port 80.

6. Change raspberry pi default password.
Open terminal under the user you want to change the password. Don't forget there are 2 users (pi and root).
Use the command passwd and you'll be prompted for the current password first and then the new password. You will see the following result if you successfully change the password. To change root's password, you must use the command:
sudo su

Result after change the password:
Changing password for pi. (current)
UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

7. Raspnian uses 2GB of the SD card. Now you should mount (automatically) the rest GB to store your data (I used the directions described here).
First check the partitions:
cat /proc/partitions

You should see the result:
major minor #blocks name
179 0 15752192 mmcblk0
179 1 57344 mmcblk0p1
179 2 1832960 mmcblk0p2
179 3 13857792 mmcblk0p3

You can use fdisk to create the parititon. Use th following command and press the following letters:
sudo fdisk /dev/mmcblk0p3
press enter
press enter w

Now format the partition:
sudo mkfs.ext4 /dev/mmcblk0p3

Create a directory to mount the partition:
sudo mkdir /media/data

Now add partition to fstab to automount everytime you reboot.
sudo nano /etc/fstab

# and add the following line
/dev/mmcblk0p3 /media/data ext4 defaults 1 0

8. Now it's time to install owncloud. I used some commands as described here.

First install what ownCloud needs (one line):
sudo apt-get install apache2 php5 php5-gd php5-sqlite libcurl4-openssl-dev php5-curl php5-common php-xml-parser sqlite

Now create a directory named data in the partition you created before (step 7) and give the right permissions:
sudo mkdir /media/data/data
sudo chown -R www-data:www-data /media/data/data

Now download the latest version from the downlod page. Remember, you want the .tar version. After download, you should untar the file. Be careful, the numbers must be different in your case.
sudo tar -xjf owncloud-5.0.0.tar.bz2

Then move (or copy) the directory to your server directory (/var/www/) and change permissions.
sudo cp -r owncloud /var/www
sudo chown -R www-data:www-data /var/www/owncloud

Now open your browser at http://STATIC_IP/owncloud (static IP is the one you set on step 4).
At the first page, use the user-root for the pi, click the advanced button.
There, leave the SQLite and localhost and at the data directory use /media/data/data (step 8, above). Click Finish and you're all set.

9. Open the fle php.ini and change the following values.
sudo nano /etc/php5/apache2/php.ini

#find the values
upload_max_filesize = 2M
post_max_size= 2M

Increase the file size you are allowed to upload from 2MB to 1000MB.

10. If you want more security, you can check the tutorial here. Change the SSH port (step 3) and create SSH keys (step 7). This way, you'll have secure access to change your installation ONLY from your computer.

Check out the conectivity:
owncloud on Raspberry Pi using Raspbian

1 σχόλιο:

  1. Πολύ βοηθητικό άρθρο, και αυτό και τα υπόλοιπα για το owncloud!
    Έχεις κάνει να συνδέεσαι με https? Ξέρεις τον τρόπο;


Από το Blogger.