LightTPD and CakePHP setup in subdirectories
I faced the challenge to install CakePHP under LightTPD. All works smoothly as long as I deploy projects in document root of domain. But when I want to setup CakePHP in subdir all goes wrong.
The source of the problem is env('PHP_SELF'). In the default LightTPD/PHP instalation it is not working. You should tweak some settings.
Download code
- Add cgi.fix_pathinfo = 1 in your php.ini
- Add "broken-scriptfilename" => "enable" into lighttpd.conf at fastcgi.server section.
- Add '/subdir' into rewrite rules to emulate apache's RewriteBase
- In webroot/index.php define('WEBROOT_DIR', basename(dirname(dirname(__FILE__))));
Download code
fastcgi.server = ( ".php" =>
((
"socket" => "/usr/local/lighttpd/fcgi/wortex/socket",
"check-local" => "disable",
"broken-scriptfilename" => "enable"
))
)
$HTTP["host"] == "example.com" {
server.document-root = "/var/www/example.com/"
url.rewrite-once = (
"/project1/(css|files|img|js|stats)/(.*)" => "/project1/webroot/$1/$2",
"^/project1/([^.]+)$" => "/project1/index.php?url=$1",
"/project2/(css|files|img|js|stats)/(.*)" => "/project2/webroot/$1/$2",
"^/project2/([^.]+)$" => "/project2/index.php?url=$1"
)
}
'project1' and 'project2' are dirs made by bake.php. Url in browser looks like http://example.com/project1/controller/action
Comments
Comment
1 Not compatible with other developers in a team environment
Comment
2 You may create custom index.php
Comment
3 Lighthttpd Without the Subdirectory
url.rewrite-once = (
"/(.*)\.(.*)" => "$0",
"/(css|files|img|js)/" => "$0",
"^/([^.]+)$" => "/index.php?url=$1"
)
More info check out this thread on google groups
http://groups.google.com/group/cake-php/browse_thread/thread/2e1c408e723551e9/59d93ccb66552419?lnk=gst&q=lighttpd&rnum=7#59d93ccb66552419
Don't forget to turn on mod_rewrite :)
Comment
4 Solution to getting Cake 1.1 running on Lighttpd 1.5
http://thefaultandfracture.blogspot.com/2007/10/enabling-cakephp-11-on-lighttpd-15.html
Comment
5 for test suite
"^/(test.php)(.*)$" => "/test.php$2",
to url.rewrite-once for testing in 1.2
url.rewrite-once= (
"/(css|files|img|js|stats)/(.*)" => "/$1/$2",
"^/(test.php)(.*)$" => "/test.php$2",
"^(.*)$" => "/index.php?url=$1"
)
Comment
6 parseExtensions for 1.2
url.rewrite-once = (
"/(css|files|img|js|stats)/(.*)" => "/$1/$2",
"^/(.+)/?$" => "/index.php?url=$1"
)