2007-08-08

papaya CMS on Lighttpd

Our current development system is Apache httpd. But it can run on Lighttpd, too. First you need to activate the mod_rewrite and define a set of rewrite rules in the configuration file.
url.rewrite-once = (
# admin pages
"^/?(?:sid[a-z]*(?:[a-zA-Z0-9,-]{32}|[a-zA-Z0-9,-]{40})/)?papaya/module\_([a-z\_]+)\.[a-z]{3,4}(?:\?(.+))?$" => "/papaya/module.php?p_module=$1&$2",
# pages
"^/?(?:sid[a-z]*(?:[a-zA-Z0-9,-]{32}|[a-zA-Z0-9,-]{40})/)?[a-zA-Z0-9_-]+(?:(?:\.[0-9]+)?\.[0-9]+)(?:(?:\.[a-z]{2,5})?\.[a-z]+)(?:(?:\.[0-9]+)?.preview)?(\?.+)?$" => "/index.php$1",
# index page
"^/?(?:sid[a-z]*(?:[a-zA-Z0-9,-]{32}|[a-zA-Z0-9,-]{40})/)?index(?:(?:\.[a-z]{2,5})?\.[a-z]+)(?:(?:\.[0-9]+)?.preview)?(\?.+)?$" => "/index.php$1",
# media files
"^/?(?:sid[a-z]*(?:[a-zA-Z0-9,-]{32}|[a-zA-Z0-9,-]{40})/)?[a-zA-Z0-9_-]+\.(?:media|thumb|download|popup|image)(?:\.(preview))?(?:(?:\.(?:[a-zA-Z0-9_]+))?(?:\.[a-zA-Z0-9_]+))(\?.+)?$" => "/index.php$1",
# sid only
"^/?(?:sid[a-z]*(?:[a-zA-Z0-9,-]{32}|[a-zA-Z0-9,-]{40}))(/.*)(\?.+)?$" => "$1$2"
)
Next you need to define the 404 handler for alias handling:
server.error-handler-404   = "/index.php"
The last step is a little bugfix in ~/papaya/inc.conf.php. Lighttpd sets $_SERVER['PATH_TRANSLATED'], but it is empty. So this check needs a little patch:
if (isset($_SERVER['PATH_TRANSLATED']) && $_SERVER['PATH_TRANSLATED'] != '') {
This way papaya CMS will use $_SERVER['SCRIPT_FILENAME']. We fixed this in the development version already. It will be included in the next public version.

No comments:

Post a Comment

x