Lighthttpd configuration for kirby


I use lighttpd with kirby and I installed it successfully.

But for the panel I get a 404.

What is the mod rewrite syntax supposed to be ?

I followed but that doesn’t work.

My lighttpd.conf is

server.modules = (
#       "mod_rewrite",

server.document-root        = "/var/www/"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"             = "/var/run/"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 80

index-file.names            = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

    # default listening port for IPv6 falls back to the IPv4 port
    ## Use ipv6 if available
#include_shell "/usr/share/lighttpd/ " + server.port
include_shell "/usr/share/lighttpd/"
include_shell "/usr/share/lighttpd/"

mod_rewrite is commented out because it is already loaded as module from cli.

and my rewrite.conf is

# /etc/lighttpd/conf-available/20-rewrite.conf

server.modules += ( "mod_rewrite" )

$HTTP["host"] == "" {
    url.rewrite-once = (
        "^/content/(.*)\.txt$" => "/index.php",
        "^/(site|kirby)/(.*)$" => "/index.php"

    url.rewrite-if-not-file = (
        "^/panel/(.*)$" => "/panel/index.php",
        "^/(.*)$" => "/index.php"

What am I doing wrong?

Please check these two things:

  • Is the file 20-rewrite.conf actually being loaded by the server?
  • Have you changed the domain to your actual domain?

Yes, it is being loaded.

I changed the domain to the servers IP address since no domain is yet to connected. But that should easily work.
Actually I should be able to remove the host line and it should still work.

Thanks for chiming in!

All files are also in /var/www/ document root directory.

I chmod all of them to 755 as well. ( though they are still owned by root but that shouldn’t be an issue.)

Does it work if you visit any other page but the homepage of your site (for example /about)? So only the Panel does not work?

Which kind of 404 do you get for the Panel? One generated by Lighttpd or one generated by Kirby?

About also does not work…

404 - Not Found…generated by lighty.

But that means that your rewriting rules aren’t effective and don’t apply to the requests. Could you please check that the file really is loaded by putting in some nonsense and checking whether that generates a syntax error?

Yes it does:

root@Blog:/var/www# service lighttpd restart
2015-11-29 17:52:36: (configfile.c.957) source: /etc/lighttpd/conf-enabled/20-rewrite.conf line: 13 pos: 5 parser failed somehow near here: fsfs
2015-11-29 17:52:36: (configfile.c.957) source: /usr/share/lighttpd/ line: 6 pos: 1 parser failed somehow near here: (EOL)
2015-11-29 17:52:36: (configfile.c.957) source: /etc/lighttpd/lighttpd.conf line: 30 pos: 1 parser failed somehow near here: (EOL)

OK. And what if you use the following syntax:

server.modules += ( "mod_rewrite" )

url.rewrite-once = (
    "^/content/(.*)\.txt$" => "index.php",
    "^/(site|kirby)/(.*)$" => "index.php"

url.rewrite-if-not-file = (
    "^/panel/(.*)$" => "panel/index.php",
    "^/(.*)$" => "index.php"

Otherwise I’m afraid I can’t really help you (Lighttpd is no officially by Kirby supported web server). Maybe there’s someone else in the forum who can help you though.

I am not sure what it was but suddenly it works.

I cannot pinpoint what the problem was unfortunately.

Thank you for helping me out :wink:

While the above config worked for most things, file uploads failed, so I had to add $0 at the end of index.php in some places, that seems to have solved the upload problem.

>     url.rewrite-if-not-file = (
>         "^/panel/(.*)$" => "/panel/index.php$0",
>         "^/(.*)$" => "/index.php$0"
>     )