Lighttpd config for multisite Drupal

Events happening in the community are now at Drupal community events on www.drupal.org.
Anonymous's picture
Posted by Anonymous on January 30, 2012 at 11:37pm

Here is my lighttpd config. It supports shortened URLs for the /files & /themes.

$SERVER["socket"] == ":80" {

###
# drupal specific stuff
###

# Deny access to backup_migrate module dumps
$HTTP["url"] =~ "^(/sites/(.)/files/backup_migrate/)" {
url.access-deny = ("")
}
$HTTP["url"] =~ "/files/backup_migrate/" {
url.access-deny = ( "" )
}

###
# drupal vhosting
###

$HTTP["host"] =~ "(.
).example.com$" {

### default to drupal 7
server.document-root = "/local/www/drupal-7/"
index-file.names = ( "index.php" )

### shorten /files, /themes
### 2012年01月30日 - randall
### %0 = entire hostname
### %1 = prefix of ..example.com
url.rewrite-once = ( "^/files/(.)$" => "/sites/%0/files/1ドル",
"^/themes/(.
)$" => "/sites/%0/themes/1ドル")

### clean urls for >= lighttpd 1.4.24
### Reference URL #1
### 2012年01月05日 - randall - fix for drupal 7 with image cache
url.rewrite-if-not-file = (
"^\/([^\?])\?(.)$" => "/index.php?q=1ドル&2ドル",
"^\/(.)$" => "/index.php?q=1ドル"
)

### "Fix" for Drupal SA-2006-006 (but let imagecache work)
### Reference #2
$HTTP["url"] =~ "^(\/sites\/(.
)\/files\/)" {
$HTTP["url"] !~ "^(\/sites\/(.*)\/files\/imagecache\/)" {
fastcgi.server = ()
cgi.assign = ()
scgi.server = ()
}
}
### deny access to other files directly
url.access-deny = ( "~", ".engine", ".inc", ".info", ".install", ".module", ".profile", ".test", ".po", ".sh", ".sql
", ".mysql", ".theme", ".tpl", ".xtmpl", "Entries", "Repository", "Root" )

###
# drupal vhosting
###
$HTTP["host"] == "testd6.sites.example.com" {
server.document-root = "/local/www/drupal-6/"
}
$HTTP["host"] == "testd7.sites.example.com" {
server.document-root = "/local/www/drupal-7/"
}
}

###
# end of port 80 hosting
###
}
Categories: ,

Comments

Reference URLs

Posted by macinr (not verified) on January 30, 2012 at 11:47pm
macinr's picture

My post was detected as spam if I included these URLs for reference, so trying here in the comments:

References:
1 - http://tinyurl.com/24rulps
2 - http://tinyurl.com/72qzhlh

Doesn't pass Clean URLs test on 7.15 for me

Posted by Justeco on September 19, 2012 at 4:31pm

I've tried using this info and the info here http://drupal.org/node/43782

This part in yours:

url.rewrite-if-not-file = (
"^\/([^\?])\?(.)$" => "/index.php?q=1ドル&2ドル",
"^\/(.)$" => "/index.php?q=1ドル"
)

differs from the same portion I find other places:

url.rewrite-if-not-file = (
"^\/([^\?])\?(.)$" => "/index.php?q=1ドル&2ドル",
"^\/(.*)$" => "/index.php?q=1ドル"
)

However, after spending hours trying different combination I have found different places in the forums, I have not gotten the Clean URLs test to pass.

I would be curious to see documentation of what must be done to pass the tests? What are the tests? Some sort of "this is everything Clean URLs handling requires" would help.

Is anyone getting these tests to pass with lighttpd 1.4.30 and Drupal 7.15?

I have not yet tried the mod_magnet lua setups, but they don't seem very recent, so I didn't think they were worth the effort for another failure without confirmation that they work with 7.

One problem I have is that people seem to forget to say what version they are using for things.

Drupal 7.15 & lighttpd 1.4.27

Posted by macinr (not verified) on September 19, 2012 at 5:28pm
macinr's picture

I'm using Drupal 7.15 & lighttpd 1.4.27 as of now. Here is my most recent config:

#--------------------
# cache control
#--------------------
$HTTP["url"] =~ ".html$" {
setenv.add-response-header = ( "Cache-Control" => "no-store, no-cache, must-revalidate, post-check=0, pre-check=0" )
etag.use-inode = "disable"
etag.use-mtime = "disable"
etag.use-size = "disable"
}
#--------------------
# vhost handling
#--------------------

$SERVER["socket"] == ":80" {

###
# drupal specific stuff
###

# Deny access to backup_migrate module dumps
$HTTP["url"] =~ "^(/sites/(.)/files/backup_migrate/)" {
url.access-deny = ("")
}
$HTTP["url"] =~ "/files/backup_migrate/" {
url.access-deny = ( "" )
}

###
# old way of doing this
###
## clean urls
####url.rewrite = ( "^/(?!(misc|theme|module|site))([^?]
)\??(.)$" => "/index.php?q=2ドル&3ドル" )

## clean urls
#####magnet.attract-physical-path-to = ( "/etc/lighttpd/drupal.lua" )


###
# drupal vhosting for *.example.com
###

$HTTP["host"] =~ "(.
).example.com$" {

### default to drupal 7
server.document-root = "/local/www/drupal-7/"
index-file.names = ( "index.php" )

### shorten /files, /themes
### 2012年01月30日 - randall
### %0 = entire hostname
### %1 = prefix of ..ucsb.edu
url.rewrite-once = ( "^/files/(.)$" => "/sites/%0/files/1ドル")
###"^/themes/(.
)$" => "/sites/%0/themes/1ドル")

### Deny access to backup_migrate module dumps
$HTTP["url"] =~ "^(\/sites\/(.)\/files\/backup_migrate\/)" {
url.access-deny = ("")
}

### clean urls for >= lighttpd 1.4.24
### http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ModRewrite#urlre...
### 2012年01月05日 - randall - fix for drupal 7 with image cache
url.rewrite-if-not-file = (
"^\/([^\?]
)\?(.)$" => "/index.php?q=1ドル&2ドル",
"^\/(.
)$" => "/index.php?q=1ドル"
)

### "Fix" for Drupal SA-2006-006 (but let imagecache work)
### http://www.linode.com/forums/viewtopic.php?t=5300%3E
$HTTP["url"] =~ "^(\/sites\/(.)\/files\/)" {
$HTTP["url"] !~ "^(\/sites\/(.
)\/files\/imagecache\/)" {
fastcgi.server = ()
}
}
### deny access to other files directly
url.access-deny = ( "~", ".engine", ".inc", ".info", ".install", ".module", ".profile", ".test", ".po", ".sh", ".sql", ".mysql", "
.theme", ".tpl", ".xtmpl", "Entries", "Repository", "Root" )

# make an external redirect
# from any www.host (with www.) to the host (without www.)
$HTTP["host"] =~ "^([^.]+.[^.]+.[^.]+)$" {
url.redirect = ( ".*" => "http://www.%1" )
}

I have a simple host block

Posted by Justeco on September 19, 2012 at 5:54pm

I have a simple host block like below. Is there some obvious reason it should fail?

$HTTP["host"] == "www.example.com" {
server.document-root = "/home/user/www.example.com/www"
accesslog.filename = "/home/user/www.example.com/logs/access_log"

# I've tried with and without this.
#server.error-handler-404 = "/index.php"

fastcgi.server = ( ".php" =>
( "localhost" => ( "socket" => "/tmp/userphpfastcgi.socket", ) )
)
# Tried lots of stuff like this
# url.rewrite-if-not-file = (
# "^/([^.?])\?(.)$" => "/index.php?q=1ドル&2ドル",
# "^/([^.?])$" => "/index.php?q=1ドル",
# "([a-zA-Z-.\/\?\=\&]
)" => "/index.php"
# )

# Just tried this
url.rewrite-if-not-file = (
"^\/([^\?])\?(.)$" => "/index.php?q=1ドル&2ドル",
"^\/(.)$" => "/index.php?q=1ドル"
)

# tried with and without this... I wish I knew what the tests were...
url.access-deny = ( "~", ".engine", ".inc", ".info", ".install", ".module",
".profile", ".test", ".po", ".sh", ".sql ", ".mysql", ".theme",
".tpl", ".xtmpl", "Entries", "Repository", "Root" )
}

I have some modules installed, can modules cause failures to the tests?

It seems to work, but ...

Posted by Justeco on September 19, 2012 at 6:05pm

I should note that with this config:

$HTTP["host"] == "www.example.com" {
server.document-root = "/home/user/www.example.com/www"
accesslog.filename = "/home/user/www.example.com/logs/access_log"

fastcgi.server = ( ".php" =>
( "localhost" => ( "socket" => "/tmp/userphpfastcgi.socket", ) )
)

url.rewrite-if-not-file = (
"^/([^.?])\?(.)$" => "/index.php?q=1ドル&2ドル",
"^/([^.?])$" => "/index.php?q=1ドル",
"([a-zA-Z-.\/\?\=\&])" => "/index.php"
)

url.access-deny = ( "~", ".engine", ".inc", ".info", ".install", ".module",
".profile", ".test", ".po", ".sh", ".sql ", ".mysql", ".theme",
".tpl", ".xtmpl", "Entries", "Repository", "Root" )
}

If I go to www.example.com/node/1 in my browser, it seems to work. So I know rewriting is happening. However, this is apparently not good enough to pass the Clean URLs test. Is there really no documentation on what those tests are?

Everyone, please note that

Posted by Garrett Albright on September 22, 2012 at 6:39am

Everyone, please note that the input filters seem to be mangling many of the config files posted above - specifically, asterisks in regular expressions are causing things to be italicized instead of just appearing as asterisks. Copy-and-pasting that code is going to result in problems. Those who want to share code should re-post it using the "Filtered HTML -- No Markdown" input format until this problem is fixed.

Lighttp on drupal

Posted by roynilanjan on January 10, 2015 at 8:11am

Correct way to work clean URL

More clearly ...

Posted by roynilanjan on January 10, 2015 at 8:15am

Lighttpd

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /