2009/7/15 Miguel Enrique Cobá Martinez <miguel.coba@gmail.com>
El mié, 15-07-2009 a las 01:32 -0300, Mariano Martinez Peck escribió:
> Hi folks!  I have a website which is in development with pier. As it
> is in development there was no lighttpd or apache and I wanted them to
> wait :)  But...In another thread of this mail, thanks John, I just
> realised that I want to configure my lighttpd with Pier now. The
> problem is that I know very little about lighttpd neither apache. I
> want to use lighttpd. But I don't know how to configure.
>
> I saw Miguel (Miguel pensé mandarte un mail privado pero aprovecho que
> tal vez le sirve a otro) post here:
> http://miguel.leugim.com.mx/index.php/2008/09/27/gemstones-and-fastcgi-with-lighttpd/
> and I wonder which is the difference between what configuration and
> the one I need for my pier site. I remove Gemstone and FastCGI from
> that post but I add Pier hahah.
>
> I also saw http://www.piercms.com/doc/deploy but I am using
> lighttpd :(
>
> I have lighttpd installed and listening. I am under Ubuntu 8.10.
>
> I want to statically serve:
>
> - My pictures -> I use the gallery plugins. I have those photos
> in /var/www/pictures
> - All css files. I have my own library for my website which has a
> stylesheet. But, what about the others css? should I serve ALL of
> them ?
> Would love to have them in /var/www/styles/
> - All javascript files. The same as above. All js of all libraries ?
> Would love to have them in /var/www/javascripts/
> - What about the files I upload in Pier and are stored in  ~/files
> Would love to have them in /var/www/pierFiles
>
> Thanks a lot for the help!

> Mariano
Hola Mariano,

this is what I have in a site in production right now (it is not
complete):

$HTTP["host"] == "mysite.com" {
 $HTTP["scheme"] == "http" {
   url.redirect = ( "^/(.*)" => "https://mysite.com/$1" )
 }
}
$SERVER["socket"] == "123.123.123.123:443" {
 ssl.engine = "enable"
 ssl.pemfile = "/etc/lighttpd/ssl/mysite.com/mysite.com.pem"
 ssl.ca-file = "/etc/lighttpd/ssl/mysite.com/gd_bundle.crt"

 server.name = "mysite.com"
 server.document-root = "/srv/www/mysite.com/"

 # We'll use the resources directory to host static files: images,
styles, etc

 # Rewrite the URL
 url.rewrite-once = (
   "^/resources/(.*)" => "$0",        # Unaltered
   "^/about/(.*)" => "$0",        # Unaltered
   "^/(.*)" => "/seaside/myApp$1"   # Rewritten
 )

 # Anything with seaside/myApp pass to Seaside on port 8080
 proxy.balance = "hash"
 proxy.server = (
   "/seaside/myApp" => (
     ( "host" => "127.0.0.1", "port" => 8080)
   )
 )
}
$HTTP["host"] == "blog.mysite.com" {
 server.document-root = "/srv/www/blog.mysite.com/"
 alias.url = ( "/wp-uploads/" =>
"/srv/www/wp-uploads/blog.mysite.com/" )
}

For this I have everything on https and several folders are served
direct from disk on the document root from the lighttpd.
Also, you can have a lot more sites in the same server without problem,
just like the wordpress blog section.

For your case you need something like:

server.document-root = “/var/www/”

$HTTP["host"] == "yoursite.com" {

 # We'll use the resources directory to host static files: images,
styles, etc

 # Rewrite the URL
 url.rewrite-once = (
   "^/pictures/(.*)" => "$0",        # Unaltered
   "^/styles/(.*)" => "$0",        # Unaltered
   "^/javascripts/(.*)" => "$0",        # Unaltered
   "^/styles/(.*)" => "$0",        # Unaltered
   "^/files/(.*)" => "$0",        # Unaltered
   "^/(.*)" => "/seaside/myApp$1"   # Rewritten
 )


Miguel: I am trying to see how to make it work but then I read in the documentation of mod_rewrite this: "NOTE: url rewriting does not work within a $HTTP["url"] conditional. "

In this case, the rewrite is within that conditional. I am right?

thanks!

Mariano
 


 # Anything with seaside/mySite pass to Seaside on port 8080
 proxy.balance = "hash"
 proxy.server = (
   "/seaside/myApp" => (
     ( "host" => "127.0.0.1", "port" => 8080)
   )
 )
}


For the files/ folder I don't know. According to the pier instructions,
the squeak files are stored on /srv/site/ (or /site/srv/, the
instructions have a typo, but imagine that it is /srv/site/)

So you have:

/srv/site/

and

/srv/site/files

The apache config proxy everything that doesn't exist on seaside/files/
to seaside. That is the reason for the document root for apache
in /srv/site/files/

But in the lighttpd example that I show the logic is, if it is a
specific folder, serve it directly and if it has seaside on it proxy to
seaside.

Anyway, give a couple hours and I'll send the equivalent exact and
complete config file for lighttpd and pier.

Miguel Cobá