Flexion.Org
Bad grammar and typos for total strangers
Wiki › Lighty Create Vhost
Wiki Index All Recent Edit Bottom

_ #!/bin/sh _ _ if [ -z $1 ]; then _ echo _ echo "usage : $0 www.yourserver.com --cgi" _ echo " --cgi is optional is you want the virtual web host to have /cgi-bin" _ echo _ exit _ fi _ _ VHOST=$1 _ ENABLE_CGI=0 _ _ # Get any other params _ while [ "$2" ] _ do _ case "$2" in _ --cgi) ENABLE_CGI=1;; _ esac _ shift _ done _ _ VHOST_CONF="/etc/lighttpd/conf-available/20-${VHOST}.vhost.conf" _ VIRT_HOME="/home/virtual/${VHOST}" _ _ # Create the required directories and set the file permissions. _ mkdir -p ${VIRT_HOME}/public_html/ _ mkdir -p ${VIRT_HOME}/cgi-bin/ _ mkdir -p ${VIRT_HOME}/etc/ _ mkdir -p ${VIRT_HOME}/var/log/ _ mkdir -p ${VIRT_HOME}/var/cache/compress/ _ touch ${VIRT_HOME}/etc/users.htdigest _ _ touch ${VIRT_HOME}/etc/lighttpd-custom.conf _ mkdir -p /etc/lighttpd/virtual/ _ ln -s ${VIRT_HOME}/etc/lighttpd-custom.conf /etc/lighttpd/virtual/${VHOST}-custom.conf 2>/dev/null _ _ chown -R www-data:www-data ${VIRT_HOME} _ chmod 755 ${VIRT_HOME}/cgi-bin/ _ _ # Create the vhost configuration. _ echo '$HTTP["host"] == "'${VHOST}'" {' > ${VHOST_CONF} _ echo ' server.name = "'${VHOST}'"' >> ${VHOST_CONF} _ echo ' server.document-root = "'${VIRT_HOME}'/public_html"' >> ${VHOST_CONF} _ echo ' server.errorlog = "'${VIRT_HOME}'/var/log/error.log"' >> ${VHOST_CONF} _ echo ' accesslog.filename = "'${VIRT_HOME}'/var/log/access.log"' >> ${VHOST_CONF} _ echo ' compress.cache-dir = "'${VIRT_HOME}'/var/cache/compress"' >> ${VHOST_CONF} _ echo ' auth.backend = "htdigest"' >> ${VHOST_CONF} _ echo ' auth.backend.htdigest.userfile = "'${VIRT_HOME}'/etc/users.htdigest"' >> ${VHOST_CONF} _ # Is the vhost CGI enabled? If so, setup the required stuff. _ if [ $ENABLE_CGI -eq 1 ]; then _ echo ' alias.url = ( "/cgi-bin/" => "'${VIRT_HOME}'/cgi-bin/" )' >> ${VHOST_CONF} _ fi _ echo ' # Include the custom configuration for this domain' >> ${VHOST_CONF} _ echo ' include "virtual/'${VHOST}'-custom.conf"' >> ${VHOST_CONF} _ echo '}' >> ${VHOST_CONF}

$Id: LightyCreateVhost,v 1.1 2007/12/11 16:17:31 martin Exp $

Wiki Index All Recent Edit Top
 
Valid XHTML Valid CSS Hacker