Install Lighttpd and Webdav on a Pogoplug

So when you install Debian on your Pogoplug you lose web access to your files. Here’s one way to get it back.

Install lighttpd, the lighttpd WebDAV module and the apache2-utils package (which contains the tool htpasswd which we will need later on to generate a password file for the WebDAV share) as follows:

    apt-get install lighttpd lighttpd-mod-webdav apache2-utils

Afterwards, create the directory /var/run/lighttpd and assign ownership to the www-data user and group. This directory will contain an SQLite database needed by WebDAV:

    mkdir /var/run/lighttpd/
    chown www-data:www-data /var/run/lighttpd/

Next, we enable the module mod_auth:

    lighty-enable-mod auth

… and then open /etc/lighttpd/lighttpd.conf to make sure that the modules mod_alias and mod_webdav are enabled in the server.modules stanza:

nano /etc/lighttpd/lighttpd.conf

remove the “#” from the beginning of the line that looks like

    “mod_webdav”,

save the file and exit nano. Then restart lighttpds:

    /etc/init.d/lighttpd restart

Now create a lighttpd vhost (your.servername.com) in the directory where you are putting your files. If you already have a vhost for which you’d like to enable WebDAV, you must adjust this tutorial to your situation.

First, we create the directory /var/www/web1/web and make the lighttpd user (www-data) the owner of that directory:

    cd /the-place-you-are-putting-yourfiles/
    mkdir -p your-files-directory
    chown www-data:www-data your-files-directory

next

    cd /var/www/web1
    ln -s /the-place-you-are-putting-yourfiles/your-files-directory /web

Then open /etc/lighttpd/lighttpd.conf

    nano /etc/lighttpd/lighttpd.conf

and add the following vhost to the end of the file:

    $HTTP["host"] == “your.servername.com” {
    server.document-root = “/var/www/web1/web”
    }

Afterwards we restart lighttpd:

    /etc/init.d/lighttpd restart

Now create the WebDAV password file /var/www/web1/passwd.dav with the user “username” (the -c switch creates the file if it does not exist):

    cd /var/www/web1
    htpasswd -c /var/www/web1/passwd.dav test

You will be asked to type in a password for the user test.

(Note: don’t use the -c switch if /var/www/web1/passwd.dav already exists because this will recreate the file from scratch, meaning you lose all users in that file!)

Then change the permissions of the /var/www/web1/passwd.dav file so that only root and the members of the www-data group can access it:

    chown root:www-data /var/www/web1/passwd.dav
    chmod 640 /var/www/web1/passwd.dav

Then you can modify your vhost:

    nano /etc/lighttpd/lighttpd.conf

so that it looks as follows:

    $HTTP["host"] == “your.servername.com” {
    server.document-root = “/var/www/web1/web”
    alias.url = ( “/webdav” => “/var/www/web1/web” )
    $HTTP["url"] =~ “^/webdav($|/)” {
    webdav.activate = “enable”
    webdav.is-readonly = “disable”
    webdav.sqlite-db-name = “/var/run/lighttpd/lighttpd.webdav_lock.db”
    auth.backend = “htpasswd”
    auth.backend.htpasswd.userfile = “/var/www/web1/passwd.dav”
    auth.require = ( “” => ( “method” => “basic”,
    “realm” => “webdav”,
    “require” => “valid-user” ) )
    }
    }

Finally, restart lighttpd once more:

    /etc/init.d/lighttpd restart

If you’ve setup a nameserver to point to your site you should be able to call up you site with your browser.

If all is well it should ask for your username and webdav password

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: