Owncloud 5 Server with Lighttpd, Sqlite on ArchLinux

I just installed Owncloud Server on my Raspberry PI. It was a bit harder then I had expected so I'll summarize how I did it and the issues I had. I'm using Raspberry PI (512Mb model), ArchLinux, Lighttpd 1.4.32, SQLite 3.7.17.

Lighttpd

First, install it.

pacman -S lighttpd  

The Lighttpd config file exists in /etc/lighttpd/lighttpd.conf. I made alot of changes here it's probably easiest just to show the whole file.

server.port = 80  
server.username = "http"  
server.groupname = "http"  
server.document-root = "/srv/http"  
server.errorlog = "/var/log/lighttpd/error.log"  
dir-listing.activate = "enable"  
index-file.names = ( "index.html", "index.php" )  
static-file.exclude-extensions = (".php", ".pl", ".fcgi")  
mimetype.assign = ( ".html" => "text/html", ".txt" => "text/plain", ".jpg" => "image/jpeg", ".png" => "image/png", "" => "application/octet-stream" )  
#ssl.engine = "enable"

ssl.pemfile = "/etc/ssl/owncloud/server.pem"

server.modules = (  
"mod_access",
"mod_fastcgi",
"mod_cgi"
)

$HTTP["url"] =~ "^/owncloud/data/" {
url.access-deny = ("")  
}
$HTTP["url"] =~ "^/owncloud($|/)" {
dir-listing.activate = "disable"  
}

fastcgi.server = (  
".php" => ((
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/tmp/php.socket",
"max-procs" => 4
))
)

You can test the Lighttpd configuration like this.

lighttpd -t -f /etc/lighttpd/lighttpd.conf  

PHP

Install like this.

pacman -S php-cgi  

The configuration exists in /etc/php/php.ini. There are a number of settings to change here. Here are the extensions I found was neccessary for Owncloud.

extension=curl.so  
extension=gd.so  
extension=iconv.so  
extension=openssl.so  
extension=pdo_sqlite.so  
extension=sqlite3.so  
extension=zip.so  

The document root has to be set.

doc_root = /srv/http  

I don't know exactly what this is, but it is needed =)

cgi.fix_pathinfo=1  

OpenSSL

pacman -S openssl  
mkdir /etc/ssl/owncloud  
cd /etc/ssl/owncloud  
openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes  
chmod 0600 /etc/ssl/owncloud  

Install Owncloud

Install and link the application to make it available in webserver. I like this solution better then copying the files. Now it's easier to keep it updated with Pacman.

pacman -S owncloud  
ln -s /usr/share/webapps/owncloud /srv/http/owncloud  

Time to start the webserver!

lighttpd -t -f /etc/lighttpd/lighttpd.conf #This test can save you some time!  
systemctl restart lighttpd.service  

Now you can surf into /owncloud and the application should be running. You will most likely get a response similar to this.
No database drivers (sqlite, mysql, or postgresql) installed.
PHP module zip not installed.

Please ask your server administrator to install the module.  
PHP module GD is not installed.

Please ask your server administrator to install the module.  
PHP module iconv is not installed.

Please ask your server administrator to install the module.  

I installed them one by one, and then restarted Lighttpd to see that they got installed correctly. Like php-sqlite for example.

pacman -Ss sqlite #search for sqlite  
pacman -S extra/php-sqlite #install php-sqlite  

It may be that they are just not enabled in php.ini extensions section, and/or that they are not even intalled. Like I had PHP-GD installed but had missed ;extension=gd.so in php.ini.

When all extensions are in place, you will see two input fields where you input admin user and password. Once entered it will take a very long time to submit the form! I actually gave up and did a restart of Lighttpd. After that it loaded faster.
Issues

If you have issues, there are helpful logs.

tail -f /srv/http/owncloud/data/owncloud.log  
tail -f /var/log/lighttpd/error.log  

First issue I had was that the first page got stuck hanging on "Upgrading filesystem cache". Looking at the log I found.

2013-07-22 18:28:35: (mod_fastcgi.c.2676) FastCGI-stderr: PHP Fatal error: Call to a member function raiseError() on a non-object in /usr/share/webapps/owncloud/lib/MDB2/Driver/sqlite3.php on line 898  

This is very easy to solve, just uncomment

"extension=pdo_sqlite.so" in php.ini.
extension=pdo_sqlite.so  

Second problem was admin got stuck. I got a tip that it could be PHP not being able to lookup apps.owncloud.com so I tried this.

echo "<?php echo gethostbyname('apps.owncloud.com'); ?&rt;" > /srv/http/dns.php  

And the dns.php page also got stuck. I added the entry in /etc/hosts like this, not nice but it works for now.

188.138.118.86 apps.owncloud.com apps.owncloud.com  

However, the admin page was not accessble, it also hang. In the owncloud.log I saw.

{"app":"PHP","message":"curl_setopt_array(): CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set at \/usr\/share\/webapps\/owncloud\/3rdparty\/Sabre\/DAV\/Client.php#462","level":2,"time":814}

I fixed that by commenting out open_basedir in php.ini.

;open_basedir = ...

The third thing, that definitly finally did the trick, was max-procs parameter in Lighttpd config. I had it set to 1 and I changed it to 4.

Last I recommend looking at https://forum.owncloud.org/viewtopic.php?f=8&t=10692 for performance tips.