OwnCloud through Lighttpd Optware-NG

1 - Setup Optware-NG from this guide
2 - Install Lighttpd from here
3 - Install necessary packages:

ipkg install php-xmlrpc php-gd php-curl php-zip php-mbstring php-memcached

4 - Enable xmlreader extension

echo "extension=xmlreader.so" >> /opt/etc/php.d/xmlreader.ini

5 - Download and install latest version of OwnCloud

cd /opt/share/www
wget https://download.owncloud.org/community/owncloud-9.1.3.tar.bz2 --no-check-certificate
bzip2 -cd owncloud-9.1.3.tar.bz2 | tar -xv
rm ./owncloud-9.1.3.tar.bz2

6 - Create lighttpd configuration for owncloud, just copy/paste all following lines in terminal

cat >> /opt/etc/lighttpd/conf.d/owncloud.conf << 'EOF'
$HTTP["url"] =~ "^/owncloud/data/" {
url.access-deny = ("")
}
$HTTP["url"] =~ "^/owncloud($|/)" {
dir-listing.activate = "disable"
}
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "/opt/etc/lighttpd/certs/lighttpd.pem"
ssl.use-sslv2 = "disable"
ssl.cipher-list = "TLSv1+HIGH !SSLv2 RC4+MEDIUM !aNULL !eNULL !3DES @STRENGTH"
}
$HTTP["scheme"] == "http" {
$HTTP["host"] == "OwnCloud" {url.redirect = (".*" => "https://%0$0")}
}
server.modules += ( "mod_setenv" )
$HTTP["scheme"] == "https" {
setenv.add-response-header = ( "Strict-Transport-Security" => "max-age=15768000; includeSubdomains; preload")
}
EOF

Press Enter

7 - Create ssl certificate (replace values in red if you want)

mkdir -p /opt/etc/lighttpd/certs
cd /opt/etc/lighttpd/certs
openssl req -new -x509 -days 1095 -nodes \
-subj "/C=RO/ST=Timis/L=Timisoara/O=HQT/CN=www.asusrouter.com" \
-keyout lighttpd.pem -out lighttpd.pem
chmod 400 lighttpd.pem

8 - Tweak some settings in php configuration file

sed -i "/upload_max_filesize =*/cupload_max_filesize = 512M" "/opt/etc/php.ini"
sed -i "/post_max_size =*/cpost_max_size = 512M" "/opt/etc/php.ini"
sed -i "/memory_limit =*/cmemory_limit = 32M" "/opt/etc/php.ini"
sed -i "/max_execution_time ==*/cmax_execution_time = 0" "/opt/etc/php.ini"
sed -i "/max_input_time ==*/cmax_input_time = -1" "/opt/etc/php.ini"

9 - Restart Lighttpd

/opt/etc/init.d/S80lighttpd restart

10 - Go to default router ip address and port :81/owncloud or www.asusrouter.com:81/owncloud
To access owncloud secure go to https://default-router-ip-address/owncloud, ex. https://192.168.1.1/owncloud or https://www.asusrouter.com/owncloud

owncloud-optware

11 - Choose a username and a password then press Finish setup

To access OwnCloud from wan you don't need to input port 81 anymore, use www.your-wan-ip-address/owncloud


Tested successfully on RT-AC68U, firmware v380.59, 1Tb usb hdd WD & on RT-AC56U, firmware v380.59, 32Gb usb flash Kingston


Source
SNB

Thanks @ryzhov_al@zyxmon & @alllexx

  • TeHashX

    Updated guide for v9.1.0

  • Ubun Tu

    Hi! After latest step, get error:

    Stopping web server: lighttpd
    Starting web server: lighttpd
    Duplicate config variable in conditional 2 global/HTTPurl=~^/owncloud/data/: url.access-deny
    2016-08-02 15:45:00: (configfile.c.943) source: cat /opt/etc/lighttpd/conf.d/*.conf line: 37 pos: 1 parser failed somehow near here: (EOL)
    2016-08-02 15:45:00: (configfile.c.943) source: /opt/etc/lighttpd/lighttpd.conf line: 333 pos: 1 parser failed somehow near here: (EOL)

    Please help!

    • TeHashX

      :) You did point 6 twice
      Remove owncloud.conf and try step 6 again
      services stop
      rm /opt/etc/lighttpd/conf.d/owncloud.conf
      Now step 6 and restart services
      services restart

      • Ubun Tu

        The situation has changed, but something else is interfering with

        services restart
        Stopping web server: lighttpd
        Restarting Optware-NG Installed Services...
        Starting web server: lighttpd
        Duplicate config variable in conditional 0 global: fastcgi.server
        2016-08-03 08:50:27: (configfile.c.943) source: /opt/etc/lighttpd/lighttpd.conf line: 348 pos: 1 parser failed somehow near here: (EOL)

      • TeHashX

        Open /opt/etc/lighttpd/lighttpd.conf and be sure you have only:
        http://pastebin.com/dM0K8PPh

        If not, start install all from scratch but follow the steps exactly: optware, lighttpd, owncloud...

      • Ubun Tu

        Thank you very much for your help!!!

        But there is also a small problem

        /opt/etc/lighttpd/lighttpd.conf: Permission denied

      • TeHashX

        You don't need to execute that file but open with nano
        nano /opt/etc/lighttpd/lighttpd.conf

      • Ubun Tu

        The file is very different! In order for something to begin the installation again, if anything need to be removed? If so, how to do it correctly?

      • TeHashX

        Can I assist you through team viewer?

      • TeHashX

        Send me TW id and temporary password @ https://www.hqt.ro/contact/

      • Ubun Tu

        I send

  • Asusguy

    Any way to use it with openvpn instead of wan?

    • TeHashX

      Yes, don't enable access from wan when installing lighttpd, connect through openvpn and go to 192.168.1.1:81/owncloud

      • Asusguy

        Thats it? Ok, thank you!

  • TeHashX
  • TeHashX

    Please follow step by step all guide because I managed to install successfully on different router with different configurations.
    RT-AC68U, firmware v380.59, 1Tb usb hdd WD & on RT-AC56U, firmware v380.59, 32Gb usb flash Kingston

  • TeHashX

    I think i found the solution
    sed -i "/max_execution_time ==*/cmax_execution_time = 0" "/opt/etc/php.ini"
    sed -i "/max_input_time ==*/cmax_input_time = -1" "/opt/etc/php.ini"
    /opt/etc/init.d/S80lighttpd restart
    rm /opt/share/www/owncloud/config/config.php
    Go to 192.168.1.1:81/owncloud
    Please check and leave feedback

    • Zeravlá

      Thanks for your reply.
      Sadly, this didn't work for me.

      Log:

      2016-05-14 21:13:29: (log.c.166) server started
      2016-05-14 21:13:29: (server.c.987) WARNING: unknown config-key: url.redirect (ignored)
      2016-05-14 21:13:44: (mod_fastcgi.c.2543) unexpected end-of-file (perhaps the fastcgi process died): pid: 1909 socket: unix:/tmp/php-fcgi.sock-0
      2016-05-14 21:13:44: (mod_fastcgi.c.3329) response not received, request sent: 1257 on socket: unix:/tmp/php-fcgi.sock-0 for /owncloud/index.php?, closin$
      2016-05-14 21:13:53: (mod_fastcgi.c.2543) unexpected end-of-file (perhaps the fastcgi process died): pid: 1909 socket: unix:/tmp/php-fcgi.sock-0
      2016-05-14 21:13:53: (mod_fastcgi.c.3329) response not received, request sent: 1286 on socket: unix:/tmp/php-fcgi.sock-0 for /owncloud/index.php?, closin$
      2016-05-14 21:13:59: (mod_fastcgi.c.2543) unexpected end-of-file (perhaps the fastcgi process died): pid: 1909 socket: unix:/tmp/php-fcgi.sock-0
      2016-05-14 21:13:59: (mod_fastcgi.c.3329) response not received, request sent: 1286 on socket: unix:/tmp/php-fcgi.sock-0 for /owncloud/index.php?, closin$
      2016-05-14 21:14:04: (mod_fastcgi.c.2543) unexpected end-of-file (perhaps the fastcgi process died): pid: 1909 socket: unix:/tmp/php-fcgi.sock-0
      2016-05-14 21:14:04: (mod_fastcgi.c.3329) response not received, request sent: 1306 on socket: unix:/tmp/php-fcgi.sock-0 for /owncloud/index.php?, closin$
      2016-05-14 21:14:11: (mod_fastcgi.c.2543) unexpected end-of-file (perhaps the fastcgi process died): pid: 1909 socket: unix:/tmp/php-fcgi.sock-0

      • TeHashX

        I just installed all from scratch on a usb flash and working well, no more errors in log.
        Can I help you through team viewer?

      • Zeravlá

        Sure, where we can chat?
        Also, you can this night? (at 7 pm, AST time)

      • Zeravlá

        7 or later :p

      • TeHashX
    • Zeravlá

      Whoops, I accidently copied yesterday log.
      But it's the same error.

      Log:

      2016-05-15 09:43:48: (log.c.166) server started
      2016-05-15 09:43:48: (server.c.987) WARNING: unknown config-key: url.redirect (ignored)
      2016-05-15 09:44:18: (mod_fastcgi.c.2543) unexpected end-of-file (perhaps the fastcgi process died): pid: 782 socket: unix:/tmp/php-fcgi.sock-0
      2016-05-15 09:44:18: (mod_fastcgi.c.3329) response not received, request sent: 1380 on socket: unix:/tmp/php-fcgi.sock-0 for /owncloud/index.php?, closing$

  • Zeravlá

    Same problem as the others.
    error 500

    Log:
    2016-05-14 20:34:43: (mod_fastcgi.c.2543) unexpected end-of-file (perhaps the fastcgi process died): pid: 948 socket: unix:/tmp/php-fcgi.sock-0
    2016-05-14 20:34:43: (mod_fastcgi.c.3329) response not received, request sent: 2170 on socket: unix:/tmp/php-fcgi.sock-0 for /owncloud/index.php?,$

    • Zeravlá

      installed in a HDD.

  • TeHashX

    Updated guide for v9.0.2

    Version 9.0.2 May 4 2016

    Open sidebar when clicking in the right part of rows in files view - #23381
    user_ldap: Call to a member function setEMailAddress() on a non-object - #23759
    Fatal error in dav app while running cron job - #23496
    Desktop sync fails with big files (OC 8.2.0, client 2.0.2) - #20261
    Wrong image rotation - #21485
    Restrict autoloaded paths to loaded apps (and other enhancements) - #18839
    Exclude autoload_static.php - #23935
    [encryption] Recovery key feature doesn't work when a not default "User Home Folder Naming Rule" is used - #23632
    Federated sharing: volatile edit permission - #24032
    Transfer ownership with encryption break files -> bad signature - #24095
    TextEditor: Checksum not invalidated on file change - #23782
    occ files:scan does not invalidate checksums if file changed on disk. - #23783
    [9.0] handle completely unscanned storages in the background scanner - #23576
    [stable9] Write .htaccess also from CLI - #24136
    Share link: user mail is disappearing after selecting expiration date - #22947
    Folder size not propagated when uploading as share recipient with encryption enabled - #24105
    Can create events in contacts_birthday calendar - #24154
    [stable9] Ignore certificate file if it starts with file:// - #24172
    [stable9] remember email when setting expiration date - #24149
    cron.php does not exit, consumes RAM - #23621
    Cron gives errors on getQuota() on null in apps/files_versions/lib/storage.php on line 691 - #23513
    [9.0] Change the sort order of background jobs to be DESC instead of ASC - #24196
    No "Personal" calendar created for installing user - #24082
    [9.0] dont do optimized size propagation for encrypted files - #24158
    [stable9] on clone Connection, do not take over the existing LDAP resource - #24236
    [stable9] Fix LDAP race conditions - #24242
    Catching undefined exception in versions expire - #24233
    [9.0] Call private cache methods only for OC\Files\Cache\Cache - #24202
    "Deadlock found when trying to get lock" in file locking - #20555
    [stable9] don't get the config for the same mount multiple times - #24259
    Scanner doesn't propagate etags any more when file changed - #24255
    Undefined index: extension at /var/www/owncloud/lib/private/installer.php#272 - #24228
    [stable9] Disable pastezone for jquery.fileupload - #24281
    Can't upgrade to 9.0.1 (daily) in CentOS 6.6 - #24276
    [9.0] error out if a local storage isn't setup correctly - #24289
    [Stable 9] Make ownCloud work again in php 7.0.6 - #24343
    After switching to Postgresql changing any activity checkbox checks all of the boxes - #23761
    Upgrade from o.C. 8.2.X to 9.0.X. Cannot access to oC if and LDAP user that made a share was deleted from the LDAP server. - #24090
    Update sabre/dav to 3.0.9 for windows 10 support - 3rdparty/#269
    Update sabre/dav to 3.0.9 on stable9 - 3rdparty/#270
    Spinning wheel OC 9 - activity/#481
    wrong links in RSS feed - activity/#508
    Announcementcenter is listing only the last 5 announcements - announcementcenter/#67
    Export Addressbook - contacts/#248
    [stable9] Redirect page if not shown in an iframe - files_pdfviewer/#109
    Fix wrong path to lost password template - templateeditor/#43
    3rdparty folder not overwritten on update - updater/#316
    getExtractionBaseDir should be deleted before code signature is verified - updater/#318
    BrokenUpdaterRepair SQL issue - updater/#331
    Wrong app path when optional PCNTL module was not enabled - updater/#335
    integrity-check command shows error after running updater from 9.0.1 stable to daily stable9 - updater/#342
    updater/update.log has to be stored in the data folder - updater/#317
    3rdparty folder not overwritten on update - updater/#316
    getExtractionBaseDir should be deleted before code signature is verified - updater/#318
    Upgrade from 9.0 to 9.1 fails - updater/#336
    Wrong app path when optional PCNTL module was not enabled - updater/#335

  • thefooldog

    Getting an error after restarting Lighttpd in step 9... it's probably simple but my abilities here are very basic!

    Duplicate config variable in conditional 2 global/HTTPurl=~^/owncloud/data/: url.access-deny
    2016-05-05 12:18:41: (configfile.c.943) source: /opt/etc/lighttpd/lighttpd.conf line: 352 pos: 1 parser failed somehow near here: (EOL)

    anyone have any ideas?

    • TeHashX

      You pasted twice lines from point 6
      Open lighttpd.conf file and delete the last 15 lines or install all from scratch starting with point 1

      $HTTP["url"] =~ "^/owncloud/data/" {
      ...
      }

      • thefooldog

        Yep, I caught it, thanks so much!!! Getting a 500 Internal Server Error though after attempting to Finish Setup of Owncloud. Off to research that!!

      • TeHashX

        Refresh web page or reboot the router

      • Jeff

        I too am getting a 500 Internal Server Error after attempting to Finish Setup of Owncloud. Lighttpd and PHP 5.6.19 are installed corrected and work fine, but the actual owncloud setup after pushing the "Finish Setup" button returns the error. I've reset the router and refreshed the page too. Is there anything else? Where is the error log stored?

      • TeHashX

        Did you enabled swap?

      • Jeff

        Yes. I've followed the guide exactly after formatting a 2GB SD stick to ext3.

        Thanks for looking into this. I can give you SSH access if you PM/email me.

      • TeHashX

        I installed from scratch and get the same "500 Internal Server Error" but after refreshing the webpage, owncloud interface is showing up :)
        Log it's in /opt/var/log/lighttpd/error.log

      • Jeff

        2016-05-12 14:52:33: (mod_fastcgi.c.2543) unexpected end-of-file (perhaps the fastcgi process died): pid: 1074 socket: unix:/tmp/php-fcgi.sock-0
        2016-05-12 14:52:33: (mod_fastcgi.c.3329) response not received, request sent: 1381 on socket: unix:/tmp/php-fcgi.sock-0 for /owncloud/index.php?, closing connection

        I can get to the login screen but it continues to give a 500 error. The above log file seems to be the cause. I haven't looked into the reason yet, but perhaps this is just too small a swap file?

      • TeHashX

        Increase memory
        sed -i "/upload_max_filesize =*/cupload_max_filesize = 512M" "/opt/etc/php.ini"
        sed -i "/post_max_size =*/cpost_max_size = 512M" "/opt/etc/php.ini"
        Restart lighttpd
        /opt/etc/init.d/S80lighttpd restart
        Remove old conf
        rm /opt/share/www/owncloud/config/config.php
        Run setup again
        192.168.1.1:81/owncloud

      • Jeff

        Completed all of the above and the same error shows up in the lighttpd log file after an Error 500. Refreshed page and rebooted - same result. :(

      • TeHashX

        Strange, try to increase swap file size to 2G
        cd /opt
        swapoff /opt/swap
        rm /opt/swap
        dd if=/dev/zero of=swap bs=1024 count=2097152
        mkswap swap
        chmod 0600 swap
        swapon swap
        And try again
        Remove old conf
        rm /opt/share/www/owncloud/config/config.php
        Run setup again
        192.168.1.1:81/owncloud

      • Jeff

        I tried this as well and still no go. I had to format a bigger USB stick as I was using a 2GB one. Same result, same error code in the log file. :( I have 3 drives plugged in, 2 NTFS drives (1TB, 2TB) and an 8GB stick. The USB stick mounted as /dev/sdc although I'm pretty sure that has nothing to do with the problem.

      • TeHashX

        Why don't you say so?
        Usb sticks are not recommended, try to install optware-ng on a usb hdd formatted as ext3/4

SUBSCRIBE

To be notified by email when a new tutorial is posted :)