Athena
Posts: 58
Joined: Tue Aug 06, 2013 5:46 am

Installation of OwnCloud 7 on Raspberry Pi

Tue Jan 13, 2015 4:42 am

Hello,

I finally got Owncloud installed and working on my Raspberry Pi server. I got a lot of help from you all. Here is my thank you; the detailed notes of my installation which uses OwnCloud 7, php5, MySql, and Apache2.

After starting Raspberry, change login to root so that you do not need to type sudo for every command.

Code: Select all

$ sudo -i
1. Update system

Code: Select all

# apt-get update
# apt-get upgrade
# apt-get dist-upgrade
# reboot
2. Get ownCloud relesase key (http://software.opensuse.org/download/p ... e=owncloud)

Code: Select all

# wget http://download.opensuse.org/repositories/isv:ownCloud:community/Debian_7.0/Release.key
3. Add owncloud repository to apt-get

Code: Select all

# apt-key add - < Release.key
# echo 'deb http://download.opensuse.org/repositories/isv:ownCloud:community/Debian_7.0/Release.key' >> /etc/apt/sources.list.d/owncloud.list
4. Install owncloud

Code: Select all

# apt-get update
# apt-get install owncloud
5. When prompted to provide a password for the MySql server enter password twice:
Root password: mysqlpsswd

6. Modify php.ini for upload file size

Code: Select all

# cd /etc/php5/apache2/
# nano php.ini
and change the following in the file for up to 2GB uploads

upload_max_filesize = 2G (2M)
post_max_size = 2G (8M)
output_buffering = 0 (4096)

7. Prepare an External USB Drive for data storage

a) Install ntfs

Code: Select all

# apt-get install ntfs-3g 
b) Create a directory for files

Code: Select all

# mkdir /media/OwnCloud
c) Mount the drive

Code: Select all

# mount –t ntfs-3g –o umask=007,auto,user,users,uid=33,gid=33 /dev/sda1 /media/
e) Check if the drive is mounted

Code: Select all

# blkid –c /dev/null
  • /dev/mmcblk0p1: SEC_TYPE="msdos" LABEL="boot" UUID="787C-2FD4" TYPE="vfat"
    /dev/mmcblk0p2: UUID="3d81d9e2-7d1b-4015-8c2c-29ec0875f762" TYPE="ext4"
    /dev/sda1: LABEL="OwnCloud" UUID="EAE0455CE0452FDD" TYPE="ntfs"
    /dev/sda2: LABEL="SERVICEV001" UUID="B641-A4FF" TYPE="vfat"
f) Find about drives

Code: Select all

# fdisk -l
  • Disk /dev/mmcblk0: 31.9 GB, 31914983424 bytes
    4 heads, 16 sectors/track, 973968 cylinders, total 62333952 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00090806

    Device Boot Start End Blocks Id System
    /dev/mmcblk0p1 8192 122879 57344 c W95 FAT32 (LBA)
    /dev/mmcblk0p2 122880 62333951 31105536 83 Linux

    Disk /dev/sda: 160.0 GB, 160041885696 bytes
    240 heads, 63 sectors/track, 20673 cylinders, total 312581808 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0xed1f86f7

    Device Boot Start End Blocks Id System
    /dev/sda1 * 2048 300296191 150147072 7 HPFS/NTFS/exFAT
    /dev/sda2 300296192 312578047 6140928 12 Compaq diagnostics
g) Create a fstab file so that this drive is mounted each time the system is rebooted.

Code: Select all

# cd /etc/fstab
# nano stab 
and enter the line in bold
  • proc /proc proc defaults 0 0
    /dev/mmcblk0p1 /boot vfat defaults 0 2
    /dev/mmcblk0p2 /ext4 defaults,noatime 0 1
    UUID=EAE0455CE0452FDD /media/OwnCloud/ ntfs-3g rw,umask=007,auto,user,users,uid=33,gid=33,utf8 0 0

    # a swapfile is not a swap partition, so no using swapon|off from here on, use dphys-swapfile swap[on|off] for that
h) Restart RPi

Code: Select all

# reboot
8. Secure connections

Code: Select all

# chown -R root:root /media/OwnCloud/
# chmod -R 755 /media/OwnCloud/
# chown www-data:www-data /media/OwnCloud/config/config.php
# chmod 750 /media/OwnCloud/config/config.php
# chown -R www-data:www-data /media/OwnCloud/data/
# chmod -R 750 /media/OwnCloud/data/
# chown root:root /media/OwnCloud/data/.htaccess
# chmod 755 /media/OwnCloud/data/.htaccess
# chown www-data:www-data /media/OwnCloud/apps/
# chmod 750 /media/OwnCloud/apps/
9. Check if the right permission are given

Code: Select all

# ls -l /dev/disk/by-uuid/
  • total 0
    lrwxrwxrwx 1 root root 15 Dec 24 22:02 3d81d9e2-7d1b-4015-8c2c-29ec0875f762 -> ../../mmcblk0p2
    lrwxrwxrwx 1 root root 15 Dec 24 22:02 787C-2FD4 -> ../../mmcblk0p1
    lrwxrwxrwx 1 root root 10 Dec 24 22:02 B641-A4FF -> ../../sda2
    lrwxrwxrwx 1 root root 10 Dec 25 02:13 EAE0455CE0452FDD -> ../../sda1

    All root, user and other permissions are write, read and execute.
10. Create SSL certificates

Code: Select all

# mkdir /etc/apache2/ssl
# openssl req -x509 –nodes –days 365 –newkey rsa:2048 –keyout /etc/apache2/ssl/apache.key –out /etc/apache2/ssl/apache.crt
Country code: US
State name: State Name
Locality name: Town
Organization Name:
Unit name:
Common Name: www.myserver.com
Email: user@email.com

11. Modify Apache

a) First check Apache version number

Code: Select all

# apachectl –v or # apache2 -v
Example output:
  • Server version: Apache/2.2.22 (Debian)
    Server built: Jul 24 2014 21:45:57
b) Edit /etc/apache2/sites-available/default-ssl to setup server name and enter location of ssl files given below in bold:

Code: Select all

# nano /etc/apache2/sites-available/default-ssl
  • <IfModule mod_ssl.c>
    <VirtualHost _default_:443>
    ServerAdmin webmaster@localhost
    ServerName www.myserver.com:443

    DocumentRoot /var/www
    <Directory />
    Options FollowSymLinks
    AllowOverride None
    </Directory>
    <Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined

    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/apache.crt
    SSLCertificateKeyFile /etc/apache2/ssl/apache.key

    <FilesMatch "\.(cgi|shtml|phtml|php)$">
    SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /usr/lib/cgi-bin>
    SSLOptions +StdEnvVars
    </Directory>

    BrowserMatch "MSIE [2-6]" \
    nokeepalive ssl-unclean-shutdown \
    downgrade-1.0 force-response-1.0
    # MSIE 7 and newer should be able to use keepalive
    BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

    </VirtualHost>
    </IfModule>
12. Enable SSL

Code: Select all

# a2enmod ssl
# a2ensite default-ssl
# service apache2 restart
13. Using your browser login to owncloud

Code: Select all

https://www.myserver.com/owncloud
Username: yourowncloudusername
Password: yourowncloudpassword
Data folder: /media/OwnCloud/data
Database : MySql

14. Check if configuration file is created properly:

Code: Select all

# cd /var/www/owncloud/config
# nano config.php
  • <?php
    $CONFIG = array (
    'instanceid' => 'oc080d29a834',
    'passwordsalt' => '29abed8440c4f6e34c374f35d1533ef3b',
    'secret' => 'cda3d4edeaf0eb612369d63e4f06b30cd7e3420ae6702baaa1c120897015f3c10e2d271c5fa569249b16f1239d07cb8d27618de2',
    'trusted_domains' =>
    array (
    0 => 'www.myserver.com',
    ),
    'datadirectory' => '/media/OwnCloud/data',
    'overwrite.cli.url' => 'https://www.myserver.com/owncloud',
    'dbtype' => 'mysql',
    'version' => '7.0.4.2',
    'dbname' => 'owncloud',
    'dbhost' => 'localhost',
    'dbtableprefix' => 'oc_',
    'dbuser' => 'oc_user',
    'dbpassword' => 'cab23680f3ac23eb623654521736bc1da7685c', mysqlpasswd
    'installed' => true,
    'mail_smtpmode' => 'smtp',
    'mail_smtpsecure' => 'tls',
    'mail_from_address' => 'owncloud',
    'mail_domain' => 'email.com',
    'mail_smtpauthtype' => 'LOGIN',
    'mail_smtpauth' => 1,
    'mail_smtphost' => 'smtp.mail.com',
    'mail_smtpport' => '587',
    'mail_smtpname' => 'yourusername,
    'mail_smtppassword' => 'yourpassword',
    'forcessl' => true,
    ‘debug’ => true;
    ‘loglevel’ => 0,
    );
15. Speed up PHP

a) Install apc

Code: Select all

# apt-get install php-apc
b) Edit /etc/php5/conf.d/20-apc.ini and add the following lines:

Code: Select all

# nano /etc/php5/conf.d/20-apc.ini

extension=apc.so
apc.enabled=[b]1[/b]
apc.shm_size=[b]12M[/b]*
* where this is the size of your desired cache

c) Start Apache

Code: Select all

# apachectl restart
d) Check if its working by creating a php.php info file in the web root /var/www/php.php and copy/paste:

Code: Select all

<?php
phpinfo();
?>
e) With your browser go to the web site, and scroll to APC section

Code: Select all

https://www.yourserver.com/php.php
f) Set up a password in apc.php and check stats

Code: Select all

# cd /usr/share/doc/php-apc 
# nano apc.php
enter
defaults('Adefaults('ADMIN_PASSWORD','yourpassword')

g) Rename apc.php and php.php in /var/ww to apc.phd and php.phd for security

16. To get rid of error

‘apache2: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName’ edit fqdn and enter the line below

Code: Select all

# nano /etc/apache2/conf.d/fqdn
ServerName localhost
When you run Apache you will not get this error anymore

Code: Select all

# apachectl restart
17. Setup Owncloud
Using your browser login to OwnCloud

Code: Select all

https://www.myserver.com/owncloud
a) Enter your email address
From top right choose "Personal" and enter an email user@email.com
b) Setup email
Go to "Admin" and under the "Email Server" fill in the email setup boxes
c) Create users
Enter user ID, user password, and the role (e.g. admin) for the user.
d) Enable encryption
Check encryption box
e) External Storage Support
Enter folder name OwnCloud and configuration media for the admin group:
f) In security check "Enforce HTTPS"

18. Install phpMyAdmin to manage OwnCloud database
(ref: https://www.digitalocean.com/community/ ... n-debian-7 )

a. Install the program

Code: Select all

# apt-get install phpmyadmin
• Select Apache2 for the server
• Choose YES when asked about whether to Configure the database for phpmyadmin with dbconfig-common
• Enter MySQL password: mysqlpasswd
• Enter phpmyadmin password: phpmyadminpasswd

b. Add phpmyadmin to the apache configuration

Code: Select all

# nano /etc/apache2/apache2.conf
Include /etc/phpmyadmin/apache.conf
c. Start apache2

Code: Select all

# service apache2 restart
d. Set Up the .htaccess File to work with phpmyadmin

Code: Select all

# nano /etc/phpmyadmin/apache.conf

and add the line “AllowOverride All” under “Directory Index”, making the section look like this:
  • <Directory /usr/share/phpmyadmin>
    Options FollowSymLinks
    DirectoryIndex index.php
    AllowOverride All
    [...]
e. Make a password directory

Code: Select all

# mkdir /media/OwnCloud/passwords
f. Create .htaccess for a particular user and enter the following

Code: Select all

# nano /usr/share/phpmyadmin/.htaccess

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /media/OwnCloud/passwords/.htpasswd
Require valid-user
g. Create the htpasswd file

Code: Select all

# htpasswd -c /media/OwnCloud/passwords/.htpasswd root
h. Enter and confirm password
yourowncloudpasswd

i. Restart apache

Code: Select all

# service apache2 restart
j. You can access phpMyAdmin through your browser

Code: Select all

https://www.myserver.com/phpmyadmin
user: root
password: yourphpmyadminpasswd

By choosing owncloud database, you can see all the owncloud tables:

19. Location of Log files (so that you can debug certain problems):

a) ownCloud

Code: Select all

/media/OwnCloud/data/owncloud.log
To have more debug information edit config.php and add

Code: Select all

# nano /var/www/owncloud/config/config.php

‘debug’ => true;
‘loglevel’ = > 0;

b) Apache

Code: Select all

/var/log/apache2/error.log
/var/log/apache2/access.log
c) php

Code: Select all

/var/log/php-errors.log
The plain PHP installations show error instead of logging them. To enable the error log of php you have to edit your php.ini and set these options:

Code: Select all

# nano /etc/php5/apache2/php.ini  
display_errors = off
log_errors = on
error_log = /var/log/php-errors.log
Then create this logfile with the proper permissions:

Code: Select all

# touch /var/log/php-errors.log
# chown www-data:www-data /var/log/php-errors.log
# service apache2 restart
d) Mysql

Code: Select all

/var/log/mysql.log
Last edited by Athena on Wed May 20, 2015 2:00 am, edited 3 times in total.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Installation of OwnCloud 7 on Raspberry Pi

Tue Jan 13, 2015 5:41 am

Wow, so simple! I can see this taking the online storage world by storm!

I tried apt-get install owncloud from the current Raspbian repository but I quickly got bogged down in a bunch of configuration and poor documentation. I'd still like to try it, but I think I'll download a pre-configured SD card image.

Athena
Posts: 58
Joined: Tue Aug 06, 2013 5:46 am

Re: Installation of OwnCloud 7 on Raspberry Pi

Tue Jan 13, 2015 2:42 pm

Hello ame,

No, it is not simple at all. It took many failures and reinstalls and its performance is not par with similar NAS alternatives. But it is a good exercise to learn a lot about Debian.

Where do you get the OwnCloud SD image for RPI?

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Installation of OwnCloud 7 on Raspberry Pi

Tue Jan 13, 2015 7:25 pm

I was being ironic. Never mind.

I haven't actually downloaded the image yet, I just read about it:
http://www.owncloudbook.com/owncloud-on-raspberry-pi/

Errol
Posts: 2
Joined: Thu Feb 05, 2015 5:28 pm

Re: Installation of OwnCloud 7 on Raspberry Pi

Thu Feb 05, 2015 5:33 pm

Greetings,

I am going to start setting up OwnCloud now...
(wish me luck)

Thank you for all the trouble you went to !!!

What version of OwnCloud did you install?
It looks like 7.0.3 is the latest version...?

Thanks again

Errol
:-)

Errol
Posts: 2
Joined: Thu Feb 05, 2015 5:28 pm

Re: Installation of OwnCloud 7 on Raspberry Pi

Thu Feb 05, 2015 6:50 pm

Greetings,

I am stuck on step 4...
Here is what I get:
...any ideas?
Regards
Errol

===========================================
2015-02-05 20:41:32 (10.7 MB/s) - `Release.key' saved [1003/1003]

root@raspberrypi:~# apt-key add - < Release.key
OK
root@raspberrypi:~# echo 'deb http://download.opensuse.org/repositori ... elease.key' >> /etc/apt/sources.list.d/owncloud.list
root@raspberrypi:~# apt-get update
E: Malformed line 1 in source list /etc/apt/sources.list.d/owncloud.list (dist)
E: The list of sources could not be read.
root@raspberrypi:~# apt-get install owncloud
Reading package lists... Error!
E: Malformed line 1 in source list /etc/apt/sources.list.d/owncloud.list (dist)
E: The list of sources could not be read.
E: The package lists or status file could not be parsed or opened.
=====================================================

Uytko
Posts: 1
Joined: Mon Feb 09, 2015 8:50 pm

Re: Installation of OwnCloud 7 on Raspberry Pi

Mon Feb 09, 2015 9:20 pm

"I am stuck on step 4"

According to: https://software.opensuse.org/download/ ... e=owncloud
I guess you should use:

Code: Select all

echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/Debian_7.0/ /' >> /etc/apt/sources.list.d/owncloud.list 
There is also a typo in step 6: output_buffefing -> output_buffering
I've not completed this usefull tutorial yet (I need an external HDD).

Hope it helps

cpc464
Posts: 239
Joined: Tue Jul 08, 2014 5:10 pm
Contact: Website

Re: Installation of OwnCloud 7 on Raspberry Pi

Mon Feb 09, 2015 11:53 pm

ame wrote:Wow, so simple! I can see this taking the online storage world by storm!

I tried apt-get install owncloud from the current Raspbian repository but I quickly got bogged down in a bunch of configuration and poor documentation. I'd still like to try it, but I think I'll download a pre-configured SD card image.
It can be installed in a couple of steps. I installed Owncloud 7 on the Pi 2 by just downloading the tar.gz file and unzipping it into place, then installing Apache. Also I had to install php5-sd and I think php5-sqlite. Surf to owncloud and pick a user name and password. Job done.

If you access owncloud via a domain name, it might say "unauthorized domain". Edid the file config.php in the Owncloud root directory and add your domain name:

'trusted_domains' =>
array (
0 => 'mydomain.org',
1 => '192.168.1.98',

That's about it. The OP's procedure is very comprehensive and rigorous, but you don't need all that just to try it out.
Unix engineer since 1989

cpc464
Posts: 239
Joined: Tue Jul 08, 2014 5:10 pm
Contact: Website

Re: Installation of OwnCloud 7 on Raspberry Pi

Wed Feb 25, 2015 3:20 pm

Just to put my money where my mouth is, I have written up the simple Owncloud 8 installation mentioned above:

http://unixetc.co.uk/2015/02/21/simple- ... erry-pi-2/
Unix engineer since 1989

promeneur
Posts: 1
Joined: Sun Mar 01, 2015 9:58 am

Re: Installation of OwnCloud 7 on Raspberry Pi

Sun Mar 01, 2015 10:39 am

hello

thanks for your tuto

my case :

the owncloud server :
- is behind a router with nat feature
- has a local address 192.168.0.x
- has no fqdn

my isp supplied a fix <ip address>
my isp does not supplies any fqdn corresponding to the <ip address>

<ip address> is in fact the external address of the router
the internal address of the router is 192.168.0.254 . this is the gate away for the lan.

i force the https access in owncloud server

in the router i add a tcp redirection for port 443 to <192.168.0.x>:443

my question :

i want to access to owncloud from internet not only locally.
what are the settings for

key generation
************************************************
Unit name:
Common Name: http://www.myserver.com
Email: user@email.com
************************************************

default-ssl file
************************************************
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
ServerName http://www.myserver.com:443

************************************************

config.php
***********************************************
array (
0 => 'www.myserver.com',
),
'datadirectory' => '/media/OwnCloud/data',
'overwrite.cli.url' => 'https://www.myserver.com/owncloud',
'dbtype' => 'mysql',
***********************************************
thanks
Raspberry pi B+

Return to “Advanced users”