Lighttpd-php5-vhosts — различия между версиями

Материал из OpenWiki
Перейти к: навигация, поиск
(Imported from MoinMoin)
 
м (1 версия)
 
(нет различий)

Текущая версия на 18:27, 14 октября 2008

lighttpd + ssl + fastcgi (php5) + vhosts

Пример обычного веб-сервера с fastcgi и витруальными хостами и юзанием ssl на виртуальных хостах.

Config




# mod_access, mod_accesslog and mod_alias are loaded by default
# all other module should only be loaded if neccesary
# - saves some time
# - saves memory

server.modules              = ( 
            "mod_access",
            "mod_alias",
            "mod_accesslog",
            "mod_rewrite", 

	    "mod_fastcgi",

#           "mod_redirect", 
#           "mod_status", 
            "mod_evhost",
	    "mod_simple_vhost",
            "mod_compress",
#           "mod_usertrack",
#           "mod_rrdtool",
#           "mod_webdav",
#           "mod_expire",
#           "mod_flv_streaming",
#           "mod_evasive"
 )



server.document-root       = "/var/www/"

simple-vhost.server-root = "/var/www/"
simple-vhost.default-host = "example.com"
simple-vhost.document-root = "/"

$HTTP[[host]] == "www1.example.com" {
  server.document-root = "/var/www/www1/"
  accesslog.filename = "/var/log/lighttpd/www1.example.com.access.log"
  server.errorlog = "/var/log/lighttpd/www1.example.com.error.log"
}
  
$HTTP[[host]] == "www2.example.com" {
  server.document-root = "/var/www/www2/"
  accesslog.filename = "/var/log/lighttpd/www2.example.com.access.log"
  server.errorlog = "/var/log/lighttpd/www2.example.com.error.log"
}
  

server.errorlog            = "/var/log/lighttpd/error.log"


index-file.names           = ( "index.php", "index.html", 
                               "index.htm", "default.htm" )



# mimetype.use-xattr = "enable"


accesslog.filename         = "/var/log/lighttpd/access.log"


#
# ~    is for backupfiles from vi, emacs, joe, ...
# .inc is often used for code includes which should in general not be part
#      of the document-root
url.access-deny            = ( "~", ".inc" )






# server.port               = 81





#server.error-handler-404  = "/error-handler.html"
#server.error-handler-404  = "/error-handler.php"


server.pid-file            = "/var/run/lighttpd.pid"




#server.errorfile-prefix    = "/var/www/"


dir-listing.encoding        = "utf-8"
server.dir-listing          = "disable"


#debug.dump-unknown-headers  = "enable"


#
# chroot() to directory (default: no chroot() )
#server.chroot            = "/"


server.username            = "www-data"


server.groupname           = "www-data"


compress.cache-dir          = "/tmp/lighttpd/cache/compress/"
compress.filetype           = ("text/plain", "text/html")


# status.status-url = "/server-status"
# status.config-url = "/server-config"


# url.rewrite                 = ( "^/$"             => "/server-status" )
# url.redirect                = ( "^/wishlist/(.+)" => "http://www.123.org/$1" )

#
# define a pattern for the host url finding
# %% => % sign
# %0 => domain name + tld
# %1 => tld
# %2 => domain name without tld
# %3 => subdomain 1 name
# %4 => subdomain 2 name
#
# evhost.path-pattern = "/home/storage/dev/www/%3/htdocs/"


# expire.url                  = ( "/buggy/" => "access 2 hours", "/asdhas/" => "access plus 1 seconds 2 minutes")


# rrdtool.binary = "/usr/bin/rrdtool"
# rrdtool.db-name = "/var/www/lighttpd.rrd"





$HTTP[[remoteip]] =~ "127.0.0.1" {
	alias.url += ( 
		"/doc/" => "/usr/share/doc/",
		"/images/" => "/usr/share/images/"
	)
	$HTTP[[url]] =~ "^/doc/|^/images/" {
		dir-listing.activate = "enable"
	}
}



#bar = 1
#var.mystring = "foo"


#bar += 1

#server.name = "www." + mystring + var.bar + ".com"

#index-file.names = (foo + ".php") + index-file.names
#index-file.names += (foo + ".php")




include_shell "/usr/share/lighttpd/create-mime.assign.pl"



include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

$SERVER[[socket]] == "0.0.0.0:443" {
  ssl.engine                  = "enable"
  ssl.pemfile                 = "/etc/lighttpd/example.com.pem"
  ssl.ca-file                 = "/etc/lighttpd/example.com.crt"
      
    $HTTP[[host]] == "www1.example.com" {
	server.document-root = "/var/www/www1/"
        accesslog.filename = "/var/log/lighttpd/www1.example.com.access.log"
        server.errorlog = "/var/log/lighttpd/www1.example.com.error.log"
    }
         
    else $HTTP[[host]] == "www2.example.com" {
        server.document-root = "/var/www/www2/"
	accesslog.filename = "/var/log/lighttpd/www2.example.com.access.log"
	server.errorlog = "/var/log/lighttpd/www2.example.com.error.log"
    }
	     
}
	  

fastcgi.server = ( ".php" => ((
                     "bin-path" => "/usr/bin/php5-cgi",
		     "socket" => "/tmp/php.socket"
		 )))

Автор рабочей конфигурации: sniz (на) tut.by