User Tools

Site Tools


doc:howto:owncloud

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doc:howto:owncloud [2013/07/14 22:55]
mes dead slow
doc:howto:owncloud [2015/12/11 21:03] (current)
tmomas Links changed from external to internal
Line 1: Line 1:
 +====== ownCloud on OpenWrt ======
  
 +Hint: I've installed OwnCloud on an TP-Link [[toh/​tp-link/​tl-wr2543nd|TL-WR2543ND]],​ using lighttpd and sorry, it's dead slow! :-(
 +
 + --- //unknown//
 +
 +I've also installed it on a more powerful TP_Link [[toh/​tp-link/​tl-wdr3500|TL-WDR3500]] but it's still very slow, 4-5 secs per page...
 +
 + --- //​motherjoker 2014/06/05 15:41//
 +===== Get OpenWrt =====
 +Use Attitude Adjustment or current trunk-version of OpenWrt[0], because one necessary package (php5-mod-zip) isn't available in version 10.3.1. The web resources of OpenWrt will help you figuring out what firmware you will need for your device and how to flash it.
 +
 +| {{:​meta:​icons:​tango:​48px-outdated.svg.png?​nolink}} | OpenWrt is not built with locale support by default, which is needed for ownCloud. Therefore this HOWTO only works if you compile your own OpenWRT firmware image and include full language support in the kernel. For more information see [[https://​forum.openwrt.org/​viewtopic.php?​id=45251]]. ​ |
 +
 +===== Get USB-support =====
 +ownCloud is around 30 MB and you will like to store your data somewhere. So best both is done on some external storage because small routers don't have that much.
 +Have a look in the OpenWrt-Wiki at usb.essentials [1] and usb.storage[2],​ and figure out what USB-mode your device is using (ohci or uhci) and know what filesystem is on your storage (here: ext4).
 +
 +You have to run an update of the package-lists before you can install any software
 + opkg update
 +
 +Install USB-support (this is for USB 2.0, see usb.essentials for USB 1.1 support)
 + opkg install kmod-usb2
 + insmod ehci-hcd
 +If you see messages like "​unresolved symbol usb_calc_bus_time"​ try loading usbcore and then try ehci-hcd again:
 + insmod usbcore
 + insmod ehci-hcd
 +
 +Install USB-storage support
 + opkg install kmod-usb-storage kmod-usb-storage-extras block-mount kmod-fs-ext4 kmod-scsi-generic
 +
 +Create a mount-point like this
 + mkdir /mnt/sda1
 +
 +Figure out which device is your USB-stick/​drive and mount it. It helps to list /dev with the USB-device and without - in this case its /dev/sda1.
 + mount -t ext4 /dev/sda1 /mnt/sda1 -o rw,sync
 +
 +Get fstab to auto-mount the usb-stick on startup, otherwise your webserver won't come up and you have to start it after mounting manually. ( FIXME Insert how-to here)
 +Even if auto-mounting on startup works, it probably ends too late when the webserver tries to start. To make sure the webserver is up after booting, insert this line into /​etc/​rc.local before "exit 0":
 + /​etc/​init.d/​lighttpd start
 +
 +===== If <= 8MB flash: Get extroot =====
 +
 +If your device has only 8 MB of flash-memory (or even less), it is too small to get all the dependencies on it. You'll need to put the operating-system on the USB-device as well. Have a look at [[doc:​howto:​extroot]] and follow the instructions for trunk. The flavour "New external overlay variant (pivot overlay)"​ worked for me on a TP-Link WR1043ND quite well. Remember to use both steps while "​Duplicate Data": pivot overlay and pivot root.
 +
 +===== Install & configure webserver =====
 +==== use luci with httpd (default web server for luci) ====
 +May you have already the OpenWrt web-interface (luci) on your router, may you want to get the OpenWrt web-interface initially.
 +
 +If you like OpenWrt-webinterface luci, install it
 + opkg install uhttpd luci
 +
 +You're able to start uhttpd twice: Add a new uhttpd section in the /​etc/​config/​uhttpd file. And don't forget to serve luci on another port.
 +
 +|''​
 +config uhttpd owncloud
 +    list listen_http ​ 0.0.0.0:80
 +    list listen_http ​ 0.0.0.0:443
 +
 +    option home /​www/​owncloud
 +
 +    list interpreter ​ "​.php=/​usr/​bin/​php-cgi"​
 +
 +    option index_page ​ index.php, index.html, index.htm, default.html,​ default.htm
 +
 +...
 +
 +config uhttpd config
 +    list listen_https ​ 192.168.1.1:​81
 +    list listen_https ​ 0.0.0.0:444
 +
 +    option home  /www
 +''​|
 +
 +after a restart of uhhtp
 +
 + /​etc/​init.d/​uhttpd restart
 +
 +you should be able to reach luci under e.g. http://​192.168.1.1:​81
 +
 +==== disable httpd and use luci on lighttpd ====
 +
 +Somewhere I got the hint to use lighttpd for running ownCloud. I tried out uhttpd simultaneously - the interface looked quite broken.
 +
 +If you don't want to run two web servers simultaneously:​
 +
 +Disable uhttpd even after reboot
 +
 + /​etc/​init.d/​uhttpd disable
 + /​etc/​init.d/​uhttpd stop
 +
 +Remember, at this point you can't use luci. So install lighttpd:
 +
 + opkg install lighttpd lighttpd-mod-cgi lighttpd-mod-fastcgi lighttpd-mod-access
 +
 +//If the httpd server is located on the SquashFS, it is not recomend to remove the files// from the space, due to wasting space by doing this (learn more about SquashFS!). Otherwise you're able to remove httpd by typing
 +
 + opkg --force-depends remove uhttpd
 +
 +
 +Now configure lighttpd, to be able to use luci again.
 +
 +Edit the config-file /​etc/​lighttpd/​lighttpd.conf
 +
 +Uncomment the mod_cgi:
 +
 + server.modules = (
 +         "​mod_cgi"​
 + )
 +
 +see errors on syslog:
 + server.error-log-use-syslog = "​enable"​
 +
 +assign luci to lua
 + cgi.assign = ( "​luci"​ => "/​usr/​bin/​lua"​ )
 +
 +At this point it's possible to start the server...
 +
 + /​etc/​init.d/​lighttpd start
 + /​etc/​init.d/​lighttpd enable
 +
 + ​...and access luci again. Use e.g. http://​192.168.1.1:​81
 +
 +==== Configure lighttpd for OwnCloud ====
 +
 + server.modules = (
 + "​mod_access",​
 + "​mod_cgi"​
 + )
 +
 +
 +cause, we'll move the Luci-Server to the Port 81; we need the port 80 for the OwnCloud-Server:​
 + server.port = 80
 +
 +Set www-root for OwnCloud (We will add a new server for Luci later.): ​
 + server.document-root = "/​www/​owncloud"​
 +
 +Add these lines to secure the access to the data according to ownCloud WebServer-notes[3],​ beware that in this example the ownCloud-folder is our www-root
 +
 + $HTTP["​url"​] =~ "​^/​data/"​ {
 + url.access-deny = (""​)
 + }  ​
 +
 + $HTTP["​url"​] =~ "​^($|/​)"​ {
 + dir-listing.activate = "​disable"​
 + }
 +
 +And append a new server for luci:
 + $SERVER["​socket"​] == ":​81"​ {
 + server.document-root = "/​www"​
 + cgi.assign = ("​luci"​ => "/​usr/​bin/​lua"​)
 + }
 +
 +Due to this, remember to remove the line we have added before:
 + #​cgi.assign = ( "​luci"​ => "/​usr/​bin/​lua"​ )
 +
 +Restart the webserver with
 +
 + /​etc/​init.d/​lighttpd restart
 +
 +And make sure it's enabled for next boots:
 +
 + /​etc/​init.d/​lighttpd enabled
 +
 +Now point your browser to http://​yourhost/​index.php and see if this manual missed something. If so, please contact the author (see details below) or get an account for this wiki and fix the how-to yourself :)
 +
 +===== Install & configure PHP =====
 +Get the dirty part: php and sqlite. I am not sure if really all of these packages are necessary, but it seems so:
 + opkg install php5 php5-cgi php5-fastcgi php5-mod-json php5-mod-session php5-mod-zip libsqlite3 zoneinfo-core php5-mod-pdo php5-mod-pdo-sqlite php5-mod-ctype php5-mod-mbstring php5-mod-gd sqlite3-cli php5-mod-sqlite3 php5-mod-curl curl php5-mod-xml php5-mod-simplexml php5-mod-hash php5-mod-dom php5-mod-iconv
 +
 +Those packages are also suggested:
 + opkg install php5-mod-mcrypt php5-mod-openssl php5-mod-fileinfo php5-mod-exif
 +
 +Configure /​etc/​php.ini to our needs and change the doc_root to our www-root:
 + ;​open_basedir=
 +
 + error_log = syslog
 +
 + doc_root =
 + cgi.fix_pathinfo=1
 +
 + memory_limit = 32M
 +
 +Check that the extensions are enabled:
 +
 +/​etc/​php5/<​extension>​.ini should contains extension=<​extension>​.ini
 +
 +Play around with memory_limit,​ I reduced the value form 8MB to 4MB ... but maybe 50MB might be better with 64MB RAM.
 +
 +run php
 + /​etc/​init.d/​php5-fastcgi enable
 + /​etc/​init.d/​php5-fastcgi start
 +
 +==== activate PHP in lighttpd.conf ====
 +
 +Uncomment to enable the fastcgi module
 + server.modules = (
 + "​mod_access",​
 + "​mod_fastcgi",​
 + "​mod_cgi"​
 + )
 +
 +Add "​index.php"​ to the list of index-file.names:​
 + index-file.names = ( "​index.php",​ "​index.html",​ "​default.html",​ "​index.htm",​ "​default.htm"​ )
 +
 + static-file.exclude-extensions = ("​.php,​ "​.pl",​ "​.fcgi"​)
 +
 +Include php by using fast-cgi (gample against max-procs for performance):​
 +
 + fastcgi.server = (
 + "​.php"​ => ((
 + "​bin-path"​ => "/​usr/​bin/​php-fcgi",​
 + "​socket"​ => "/​tmp/​php.socket",​
 + "​max-procs"​ => 1
 + ))
 + )
 +
 +Only if you are using normal cgi mode for PHP, you'll need the following line
 + cgi.assign = ("​.php"​ => "/​usr/​bin/​php-cgi"​)
 +
 +Restart the webserver with
 +
 + /​etc/​init.d/​lighttpd restart
 +
 +Now point your browser to http://​yourhost/​index.php (first create a helpful content to this file) and see if this manual missed something. If so, please contact the author (see details below) or get an account for this wiki and fix the how-to yourself.
 +
 +===== Get SSL (optional) =====
 +Probably you want to run lighttpd with SSL/https to get your traffic crypted. These instructions are taken from [4]. For generating a key you need to install libopenssl and the openssl-utils
 + opkg install libopenssl openssl-utils
 +(or openssl-util without the 's?)
 +
 +Now you can create a folder for your key like this
 + mkdir /​etc/​lighttpd/​ssl/​YOURDOMAIN -p
 +
 +Within that you can create your key with the following command. You will be asked to provide some information for the certificate.
 + openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
 +
 +Make the file only accessable to root
 + chmod 0600 /​etc/​lighttpd/​ssl/​YOURDOMAIN
 + chmod 0600 /​etc/​lighttpd/​ssl/​YOURDOMAIN/​server.pem
 +
 +Now we can uncomment the lines for SSL in lighttp.conf and modify the path to the server.pem:
 + ssl.engine = "​enable" ​                            
 + ssl.pemfile = "/​etc/​lighttpd/​ssl/​YOURDOMAIN/​server.pem"​
 +
 +Restart the webserver afterwards - don't wonder if it isn't anymore reachable via http:
 + /​etc/​init.d/​lighttpd restart
 +
 +===== unleash OwnCloud =====
 +
 +Download and unpack the newest revision:
 +
 +| ''​cd /tmp
 +wget http://​mirrors.owncloud.org/​release/​ownclound-X.X.X.tar.bz2
 +opkg update
 +opkg install tar
 +cd /www
 +tar -xjf /​tmp/​owncloud-X.X.X.tar.bz2
 +''​ |
 +
 +Now you should cleanup:
 +
 +| ''​rm /​tmp/​owncloud-X.X.X.tar.bz2
 +opkg remove --autoremove tar
 +''​ |
 +
 +You have to configure the rights of the /​www/​owncloud in addition.
 +| ''​chown -R root:root /​www/​owncloud
 +chmod 770 -R /​mnt/​sda1/​owncloud/​data
 +''​ |
 +
 +| ''​cd /mnt/sda1
 +mkdir owncloud
 +cd owncloud
 +mkdir data
 +chown -R root:root /​mnt/​sda1/​owncloud
 +chmod 770 -R /​mnt/​sda1/​owncloud
 +''​ |
 +
 +Open your Website http://​192.168.1.1/​ and configure your first steps, then wait for a loooonnnnngggg time and you'll see the result.
 +
 +=====The easiest way to install owncloud =====
 +
 +Format your USB drive as ext3 or ext4 and plug it into your Openwrt router
 +
 +download the script from gizfun.com, run it and you are good to go
 +
 +''​wget http://​www.gizfun.com/​dl/​web_for_openwrt.sh''​ #This link does not available now.
 +
 +''​sh web_for_openwrt.sh''​
 +
 +The script will download, install and configure all necessary web server components automatically. All software will be installed onto the external USB storage.
 +
 +
 +=====Owncloud on alternative destination =====
 +
 +If you don't want to set up a extroot, you can install owncloud on a different location (doc:​techref:​opkg#​mount.point)
 +
 +Install php on another location, then
 +| ''​ln -s /​opt/​etc/​php.ini /​etc/​php.ini
 +ln -s /​opt/​etc/​php5 /etc/php5
 +''​ |
 +
 +If you still get errors related timezones and calls to undefined functions:
 +| ''​opkg -dest usb install zoneinfo-core zoneinfo-[your region]
 +ln -s /​opt/​usr/​lib/​php /​usr/​lib/​php
 +ln -s /​opt/​usr/​share/​zoneinfo/​ /​usr/​share/​zoneinfo/​
 +''​ |
 +
 +TODO
 +
 +===== Known bugs =====
 +
 +  * Even if php5-mod-xml (and php5-mod-simplexml,​ -xmlreader and -xmlwriter) are installed, ownCloud lists php-xml as a missing dependency. Anyone an idea?
 +  * It can be fixed by selecting php5-mod-xml when you make php5. If you don't, libxml will not be loaded, even if phh5-mod-xml is installed later. ​
 +
 +===== Written by =====
 +Page was initiated by wetterfrosch ​
 +  * Mail: wetter_ät_netzpolitik.org
 +  * Jabber: wetterfrosch_ät_jabber.berlin.ccc.de
 +  * Diaspora: wetter_ät_diaspora.subsignal.org
 +  * Twitter: @wetterfrosch
 +
 +but a lot of modifications are done by others...
 +
 +===== Resources =====
 +
 +  * [0] http://​downloads.openwrt.org/​snapshots/​trunk/​
 +  * [1] [[doc/​howto/​usb.essentials]]
 +  * [2] [[doc/​howto/​usb.storage]]
 +  * [3] http://​owncloud.org/​support/​webserver-notes/ ​
 +  * [4] http://​www.cyberciti.biz/​tips/​howto-lighttpd-create-self-signed-ssl-certificates.html
 +  * [5] http://​www.gizfun.com/​content/​install-owncloud-your-openwrt-router-3-steps