Note: You are viewing an old version of this page. View the current version.

cd /usr/local/etc/lighttpd

# Create srv directory structure
# create: mtree -x -c -i -n -k uname,gname,mode,link,nochange -p /srv
# apply: mtree -x -e -U -f srv_www.mtree -p /srv
cat <<"EOF" | tee srv_www.mtree | mtree -x -e -U -p /srv
/set type=file uname=root gname=www mode=0755
.               type=dir gname=wheel

    www             type=dir
        conf            type=link gname=www \
                        link=../../usr/local/etc/lighttpd

        etc             type=dir mode=0750
        ..


        log             type=dir uname=www
        ..


        root            type=dir
        ..


/set type=file uname=www gname=www mode=0770
        run             type=dir uname=root mode=0750

            cache           type=dir
            ..


            home            type=dir
            ..


            sock            type=dir
            ..

        ..


        tmp             type=dir uname=root mode=01770
        ..


        vhost           type=dir uname=root mode=0755
        ..

    ..

..
EOF

mv vhosts.d sample-vhosts.d
mkdir vhost.d
chown :www vhost.d

# Patch lighttpd.conf to use srv directory structure
cat <<"EOF" | tee lighttpd.conf.diff | patch -p0
--- lighttpd.conf       2013-07-07 12:15:35.000000000 +0000
+++ lighttpd.conf       2013-07-07 23:40:17.184628687 +0000
@@ -13,11 +13,12 @@
 ## if you add a variable here. Add the corresponding variable in the
 ## chroot example aswell.
 ##
-var.log_root    = "/var/log/lighttpd"
-var.server_root = "/usr/local/www/data"
-var.state_dir   = "/var/run"
-var.home_dir    = "/var/spool/lighttpd"
-var.conf_dir    = "/usr/local/etc/lighttpd"
+var.server_root = "/srv/www"
+var.conf_dir    = server_root + "/conf"
+var.log_root    = server_root + "/log"
+var.state_dir   = server_root + "/run"
+var.home_dir    = server_root + "/run/home"
+var.temp_dir    = server_root + "/tmp"

 ##
 ## run the server chrooted.
@@ -50,7 +51,8 @@
 ## conf.d/simple_vhost.conf
 ## vhosts.d/vhosts.template
 ##
-var.vhosts_dir  = server_root + "/vhosts"
+var.vhosts_dir  = server_root + "/vhost"
+var.vhost_dir   = server_root + "/vhost"

 ##
 ## Cache for mod_compress
@@ -58,7 +60,7 @@
 ## used in:
 ## conf.d/compress.conf
 ##
-var.cache_dir   = "/var/cache/lighttpd"
+var.cache_dir   = state_dir + "/cache"

 ##
 ## Base directory for sockets.
@@ -67,7 +69,7 @@
 ## conf.d/fastcgi.conf
 ## conf.d/scgi.conf
 ##
-var.socket_dir  = home_dir + "/sockets"
+var.socket_dir  = state_dir + "/sock"

 ##
 #######################################################################
@@ -112,7 +114,7 @@
 ##
 ## Document root
 ##
-server.document-root = "/usr/local/www/data/"
+server.document-root = server_root + "/root"

 ##
 ## The value for the "Server:" response field.
@@ -370,7 +372,7 @@
 ##
 ## defaults to /var/tmp as we assume it is a local harddisk
 ##
-server.upload-dirs = ( "/var/tmp" )
+server.upload-dirs = ( temp_dir )

 ##
 #######################################################################
@@ -441,6 +443,7 @@
 ##
 #include "conf.d/config.conf"
 #include_shell "cat /usr/local/etc/lighttpd/vhosts.d/*.conf"
+include_shell "ls -1 " + conf_dir + "/vhost.d/*.conf | sed -e 's/^.*$/include '\''&'\''/'"
 ##
 #######################################################################

EOF