Owncloud 9 - How To install with Raspberry

From Linux - Help
Jump to navigation Jump to search
Owncloud 9 works great with Raspberry Pi 3

A Raspberry PI can be easly used like an owncloud server.

The goal of this document is to provide an step by step, quick guide to install owncloud and make it work with an external drive (like a USB or an external HDD).

Hardware

 Rapsberry Pi 3 / or 2
 16GB Ultra Micro SDHC UHS-I/Class 10 card
 RASPBIAN

Configure the Raspberry Pi to get the best performance

 sudo raspi-config

The following changes needs to be made in the Raspberry Pi configuration

  a. Expand the root filesystem to have enough space for the cloud  
  b. Change user password # if fresh installation.
  c. Change locale to en_US.UTF8 # not mandatory.
  d. Memory split, allocate 16M to video graphics
  e. Overclock to Modest or Medium # not needed with Raspberry Pi 3.

When it's done please update your system:

 sudo apt-get update
 sudo apt-get upgrade

Create user and group www-data:

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

Install needed 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-curl php5-gd php5-fpm memcached php5-memcache varnish


Create RSA SSL certificate valid for 2 years:

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

Change the permission:

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

Back-up the file /etc/nginx/sites-available/default:

 sudo mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default_bak

Create a new file /etc/nginx/sites-available/default:

 sudo nano /etc/nginx/sites-available/default
 upstream php-handler {
     server 127.0.0.1:9000;
     #server unix:/var/run/php5-fpm.sock;
 }

 server {
     listen 80;
     server_name  change_with_your_ip ;
     return 301 https://$server_name$request_uri; # enforce https
 }

 server {
     listen 443 ssl;
     server_name  change_with_your_ip ;
     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 1000M; # 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;
     }
 }


Configure max upload limit in php:

 sudo nano /etc/php5/fpm/php.ini
 upload_max_filesize = 2000M
 post_max_size = 2000M

Update PHP listen line:

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

Change the following line from:

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

Update the conf_swapsize:

 sudo nano /etc/dphys-swapfile

Change the following line from:

   CONF_SWAPSIZE=100
   to
   CONF_SWAPSIZE=512
 sudo reboot

Install Owncloud 9:

Type one by one in your terminal:

 sudo mkdir -p /var/www/owncloud
 sudo wget https://download.owncloud.org/community/owncloud-9.1.1.tar.bz2
 sudo tar xvf owncloud-9.1.1.tar.bz2
 sudo mv owncloud/ /var/www/
 sudo chown -R www-data:www-data /var/www
 rm -rf owncloud owncloud-9.1.1.tar.bz2

Mounting and setup an external drive:

 sudo apt-get install ntfs-3g
 sudo mkdir /media/ownclouddrive

Type and note the results:

 id -g www-data          # GID of your user group www-data
 id -u www-data          # UID of your user www-data
 ls -l /dev/disk/by-uuid # UUID of your usb / HDD you want to use for space in Owncloud.

Modify the /etc/fstab file:

 sudo nano /etc/fstab

Replace with your results UUID + UID + GID:

 UUID=F862415120154 /media/ownclouddrive auto      nofail,uid=33,gid=33,umask=0027,dmask=0027,noatime 0 0


sudo reboot
sudo ls /media/ownclouddrive  # if no file on HDD normal you get no result!


Basic First Access Setup:

1. Open your browser and enter the IP address provided, you?ll be directed to your ownCloud storage server.

2. Because we installed SSL for more security you might get a certificate error, simply add the certificate to your exception list to proceed.

3. You should be presented with a simple setup screen, Here enter a username and password to create an admin account.

4. Click on Storage & database dropdown and enter your external hard drive: /media/ownclouddrive (Skip this if you didn?t setup an external drive).

5. Click Finish setup.

Make your Owncloud available to internet:

Check your External IP (WAN IP) with monip.org and past in the follow file /var/www/owncloud/config/config.php:

 sudo nano /var/www/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', # you can add your ddns adress too or your WAN IP.

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', #WAN IP

Restart the service nginx:

 sudo service nginx restart

Now log into your router and navigate to the port forward section. Now port forward SSL port 443 to the Raspberry pi internal IP (LAN IP) address and save settings.

If IP is not static / of prefer an ddns adress please create an account and install niop.2.1.9:

To create an noip account, please follow this link: noip.

then to install the application noip.2.1.9, follow these instructions:

 cd /usr/local/src
 wget http://www.noip.com/client/linux/noip-duc-linux.tar.gz
 tar xzf noip-duc-linux.tar.gz
 cd no-ip-2.1.9change_with_your_ip 
 make
 make install

after install to run the programm type in terminal:

 sudo /usr/local/bin/noip2

To auto run edit your /etc/rc.local to include

  '/usr/local/bin/noip2' 

Online resources

Avoiderrors Owncloud How to

Youtube Raspberry PI Owncloud tuto

Youtube noip installation guide