Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Wed Jun 09, 2010 8:57 pm 
Offline
Senior Newbie

Joined: Wed Jun 09, 2010 12:28 pm
Posts: 12
Hi,
i cannot run vhosts with lighttpd. I have followed the guide from library.linode.com. But it didn't work for my vhost.
So, I have tried other examples those I found from the internet.
In all case I had the common problem.
Vhosts load files from the server.document-root path from lighttpd.conf file, but not the host-specified path.

here are the configuration files

Please, Help me to find my mistake ..

lighttpd.conf
Code:
# Debian lighttpd configuration file
#

############ Options you really have to take care of ####################

## modules to load
# 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_compress",
            "mod_rewrite",
            "mod_redirect",
            "mod_evhost",
            "mod_magnet",
            "mod_webdav",
            "mod_expire",
#           "mod_usertrack",
#           "mod_rrdtool",
#           "mod_flv_streaming",
#           "mod_evasive"
)

## a static document-root, for virtual-hosting take look at the
## server.virtual-* options
server.document-root       = "/web/default/public"

## where to upload files to, purged daily.
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )

## where to send error-messages to
server.errorlog            = "/web/default/log/error.log"

## files to check for if .../ is requested
index-file.names           = ( "index.html", "index.htm", "default.htm" )

## Use the "Content-Type" extended attribute to obtain mime type if possible
mimetype.use-xattr = "enable"

#### accesslog module
accesslog.filename         = "/web/default/log/access.log"

## deny access the file-extensions
#
# ~    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" )

##
# which extensions should not be handle via static-file transfer
#
# .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".aspx" )


######### Options that are good to be but not neccesary to be changed #######

## Use ipv6 only if available. (disabled for while, check #560837)
#include_shell "/usr/share/lighttpd/use-ipv6.pl"

## bind to port (default: 80)
# server.port               = 81

## bind to localhost only (default: all interfaces)
## server.bind                = "localhost"

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

## to help the rc.scripts
server.pid-file            = "/var/run/lighttpd.pid"

##
## Format: <errorfile-prefix><status>.html
## -> ..../status-404.html for 'File not found'
#server.errorfile-prefix    = "/var/www/"

## virtual directory listings
dir-listing.encoding        = "utf-8"
server.dir-listing          = "enable"

## send unhandled HTTP-header headers to error-log
#debug.dump-unknown-headers  = "enable"

### only root can use these options
#
# chroot() to directory (default: no chroot() )
#server.chroot            = "/"

## change uid to <uid> (default: don't care)
server.username            = "www-data"

## change uid to <uid> (default: don't care)
server.groupname           = "www-data"

#### compress module
compress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ("text/plain", "text/html", "application/x-javascript", "text/css")


#### url handling modules (rewrite, redirect, access)
# 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 module
# expire.url                  = ( "/buggy/" => "access 2 hours", "/asdhas/" => "access plus 1 seconds 2 minutes")

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

#### variable usage:
## variable name without "." is auto prefixed by "var." and becomes "var.bar"
#bar = 1
#var.mystring = "foo"

## integer add
#bar += 1
## string concat, with integer cast as string, result: "www.foo1.com"
#server.name = "www." + mystring + var.bar + ".com"
## array merge
#index-file.names = (foo + ".php") + index-file.names
#index-file.names += (foo + ".php")


#### external configuration files
## mimetype mapping
include_shell "/usr/share/lighttpd/create-mime.assign.pl"

## load enabled configuration files,
## read /etc/lighttpd/conf-available/README first
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

#### handle Debian Policy Manual, Section 11.5. urls
## by default allow them only from localhost
## (This must come last due to #445459)
## Note: =~ "127.0.0.1" works with ipv6 enabled, whereas == "127.0.0.1" doesn't
$HTTP["remoteip"] =~ "127.0.0.1" {
   alias.url += (
      "/doc/" => "/usr/share/doc/",
      "/images/" => "/usr/share/images/"
   )
   $HTTP["url"] =~ "^/doc/|^/images/" {
      dir-listing.activate = "enable"
   }
}

#$HTTP["host"] =~ "^example\.com$" {
#   server.document-root = "/web/example.com/public/"
#   server.errorlog = "/web/example.com/log/error.log"
#   accesslog.filename = "/web/example.com/log/access.log"
#   ssi.extension = ( ".html" )
#   server.error-handler-404 = "/e404.php"
#   url.redirect = ( "^/(.*)" => "http://www.example.com/$1" )
#}


10-simple-vhost.conf
Code:
## Simple name-based virtual hosting
##
## Documentation: /usr/share/doc/lighttpd-doc/simple-vhost.txt
##                http://www.lighttpd.net/documentation/simple-vhost.html

server.modules += ( "mod_simple_vhost" )

## The document root of a virtual host isdocument-root =
##   simple-vhost.server-root + $HTTP["host"] + simple-vhost.document-root
simple-vhost.server-root         = "/web"
simple-vhost.document-root       = "public"

## the default host if no host is sent
simple-vhost.default-host        = "default"

$HTTP["host"] == "example.com" {
    simple-vhost.document-root = "public"
}

$HTTP["host"] == "l.example.com" {
    simple-vhost.document-root = "public"
}

$HTTP["host"] == "example2.com" {
    simple-vhost.document-root = "public"
}


Top
   
 Post subject:
PostPosted: Thu Jun 10, 2010 5:17 am 
Offline
Senior Member

Joined: Mon Dec 07, 2009 6:46 am
Posts: 331
You can't use conditional and simple vhost at once. Check the docs:

http://redmine.lighttpd.net/projects/li ... impleVhost


Top
   
 Post subject:
PostPosted: Thu Jun 10, 2010 3:07 pm 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
Well, you can, kinda. simple_vhost makes a darned good default, but I've found I've occasionally needed to throw exceptions in. You can do this by wrapping the entirety of the simple_vhost stuff in a conditional $HTTP["host"] !~ "whatever", then do $HTTP["host"] == "whatever" to match the exceptions. But that's neither here nor there.

The original poster probably wants something like this:

Code:
server.modules += ( "mod_simple_vhost" )

simple-vhost.server-root         = "/web"
simple-vhost.document-root       = "public"
simple-vhost.default-host        = "default.example.com"


And then put the content in directories under /web:

Code:
/web/example.com/public/
/web/l.example.com/public/
/web/example2.com/public/
/web/default.example.com/public/


... with /web/default.example.com/public/ being the default should the requested hostname not be found in /web.

The trick about simple_vhost is that it is entirely based upon the existence of directories under simple-vhost.server-root. You can add and remove directories on the fly and simple-vhost will adjust accordingly without lighttpd needing to be restarted. That's what makes it simple. :-)


Top
   
 Post subject:
PostPosted: Fri Jun 11, 2010 9:00 pm 
Offline
Senior Newbie

Joined: Wed Jun 09, 2010 12:28 pm
Posts: 12
thank you for your respond.
i have faced a lot of issue with lighttpd. When i first setup it worked perfectly but when I installed mono, php and so on vhosts started not to work. And I couldn't find my mistake. I dont know even if i had :)
So, I return apache back.. Now everything works perfectly.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group