public
Description: The ultra-lightweight ultra-flexible blogging engine with a fetish for birds and misspellings.
Home | Edit | New

Other Server Software

Chyrp works almost perfectly on any server as long as it can execute .PHP files. The only catch is .htaccess/mod_rewrite support provided by Apache, but the extend of Chyrp’s requirement of that ends with redirecting requests that do not point to a file to Chyrp’s index.php. Below are the respective configurations for other servers on how to accomplish this (if you have another, please add it!).

nginx

Enable clean URL rewrites:


server {
        
        # snipped        

        if (!-e $request_filename) {
                rewrite ^/.*$ /index.php last;
        }

        # prevent twig files from being downloaded directly
        location ~ .*\.twig$ {
                deny all;
        }


        location ~.*\.php$ {
                # snipped - don't put the rewrite rule here!
        }
}

lighttpd

The easiest way is to use mod_magnet, which makes it possible to use a Lua script to rewrite URLs. This is necessary since the regular mod_rewrite is not handle to check whether a file exists or not.

This little tutorial is based on the Drupal example on the Lighttpd wiki.

So, first enable mod_magnet. Then create the following LUA file (named chyrp.lua for example):


-- little helper function
function file_exists(path)
  local attr = lighty.stat(path)
  if (attr) then
      return true
  else
      return false
  end
end
function removePrefix(str, prefix)
  return str:sub(1,#prefix+1) == prefix.."/" and str:sub(#prefix+2)
end

-- prefix without the trailing slash -- change it as needed!
local prefix = ’’

-- the magic ;)

if (not file_exists(lighty.env[“physical.path”])) then
-- file still missing. pass it to the fastcgi backend
request_uri = removePrefix(lighty.env[“uri.path”], prefix)
if request_uri then
lighty.env[“uri.path”] = prefix .. “/index.php”
local uriquery = lighty.env[“uri.query”] or ""
lighty.env[“uri.query”] = uriquery .. (uriquery ~= "" and “&” or "") .. “q=” .. request_uri
lighty.env[“physical.rel-path”] = lighty.env[“uri.path”]
lighty.env[“request.orig-uri”] = lighty.env[“request.uri”]
lighty.env[“physical.path”] = lighty.env[“physical.doc-root”] .. lighty.env[“physical.rel-path”]
end
end
-- fallthrough will put it back into the lighty request loop
-- that means we get the 304 handling for free. ;)

And then add to your config file:


$HTTP["host"] == "my-awesome-site.com" {
        index-file.names = ( "index.php" )
        url.access-deny = ( ".twig" )
        magnet.attract-physical-path-to = ( "/etc/lighttpd/chyrp.lua" )
}

Restart Lighttpd and enjoy.

Last edited by Schnouki, Tue Jul 21 04:35:31 -0700 2009
Home | Edit | New
Versions: