Main menu

Purple Technician

Din leverantör av System- och tekniklösningar inom IT-området

Tjänster Läs mer

Mjukvara

Utveckling av mjukvara

Utveckling av applikationer och spel

Läs mer
Dator

Datornätverk

Installation, konfigurering, felsökning och support av nätverk, klienter, servrar och programvaror

Läs mer
Konsult

Konsulttjänster

Systemdesign, Weblösningar, IT-säkerhet, Utbildning m.m.

Läs mer

Install Owncloud 7.01 on Raspberry Pi (Debian)

Welcome to this turorial on how to install Owncloud on a Raspberry Pi.

First follow step 1-3 on my tutorial LAMP with Raspberry Pi.

Login in as root (su) so you don't have to use sudo.

 

Step 1 - Installing the packages

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

 

Step 2 - Make sure php5-curl is not installed

apt-get --purge remove php5-curl

Step 3 - Creating your SSL certificates for 2 years

You can leave all fields blank besides Common Name which must be your domainname/ddns-name.

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

 

Step 4 - Configuring Ngnix web server

nano /etc/nginx/sites-available/owncloud
Add the entire content below:   
Note: You'll have to replace mydomain.com with the local IP of your Raspberry Pi or the domain name (make sure it matches with the details you have provided to create the certificate, else ownCloud won't work). If you have planned instead to use any Dynamic DNS domain, then use your  domain name instead of the local IP address. 
upstream php-handler {
server 127.0.0.1:9000;
}

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

server {
listen 443 ssl;
server_name mydomain.com;

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;
}
}

Step 5 - Configuring max upload limit in php

 nano /etc/php5/fpm/php.ini

Tip: Use ctrl+w to search below lines and update if needed:

upload_max_filesize = 1000M
post_max_size = 1000M

 

Step 6 - Configuring PHP 

nano /etc/php5/fpm/pool.d/www.conf
Change the following line, if needed, from:
listen = /var/run/php5-fpm.sock 
to
listen = 127.0.0.1:9000

Edit file /etc/dphys-swapfile

nano /etc/dphys-swapfile
Change the following line, if needed, from:
CONF_SWAPSIZE=100 
to 
CONF_SWAPSIZE=512
 Enable the owncloud site and disable the default site
ln -s /etc/nginx/sites-available/owncloud /etc/nginx/sites-enabled/owncloud
unlink /etc/nginx/sites-enabled/default

Step 7 - Restart web server and Php

/etc/init.d/php5-fpm restart
/etc/init.d/nginx restart

Step 8 - Install ownCloud

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

Step 9. Portforward

You probably have to port forward port 80 and 443 on tour router to your Raspberry Pi. How you do it differs from router to router.

Step 10. Setup admin account

While setting up the admin account you should provide the path to your data folder. You can ideally set this to your NAS drive or external drive which you may have mounted. Owncloud will complain and not proceed with admin account if the data directory path is not readable & writable by the user www-data. Also it should not be readable by "others".
Now in the browser, login to the ip address of Raspberry Pi or if you have configured your domain name then use that and set up the admin account.
    https://mydomain.com    or    https://192.168.XXX.XX

Step 11. Problem upgrading?

If your owncloud stays in maintenance mode then:

Stop the upgrade process this way:

cd /var/www/owncloud/
sudo -u www-data php occ maintenance:mode --off

And start the manual process:

sudo -u www-data php occ upgrade

If this does not work properly, try the repair function:

sudo -u www-data php occ maintenance:repair