[CLUG-chat] Apache VirtualHost directory structure.

Deon Bredenhann deon1 at propellerheads.co.za
Thu Aug 10 07:59:11 SAST 2006


Hi People-who-do-a-lot-of-Apache-setups.

I have the following layout for my Apache VHost layout.
I would like to re-write my newhost script, which is old and doesn't do
any checking and was just a quick fix. OK. Done with all the excuses. I
would like to write a descent one, but would first like to check the
directory structure. What do you guys/gals out there use? What does your
directories look like and why?
The /wwwroot/default has a httpd.conf with an
include /wwwroot/conf/httpd/*.conf in it.

My reasoning for the following is :
One dir for everything Apache. (Easy on backups)
>From the script you can see logs go to the normal logdir which means
logrotate will handle it automagically.

Any ideas for improvement?

Thanx 
Deon

ls -R | grep "^./"
./wwwroot:
./wwwroot/conf:
./wwwroot/conf/httpd:
./wwwroot/conf/proftpd:
./wwwroot/cron:
./wwwroot/default:
./wwwroot/ftp:
./wwwroot/scripts:
./wwwroot/webapps:
./wwwroot/webapps/default.localdomain:
./wwwroot/webapps/default.localdomain/web:




cat wwwroot/scripts/newhost.sh

#!/bin/sh

hostname=$1

mkdir /wwwroot/webapps/$hostname
mkdir /wwwroot/webapps/$hostname/web

echo "########################################################"
> /wwwroot/conf/httpd/$hostname.conf
echo "# $hostname" >> /wwwroot/conf/httpd/$hostname.conf
echo "########################################################"
>> /wwwroot/conf/httpd/$hostname.conf
echo " " >> /wwwroot/conf/httpd/$hostname.conf
echo "" >> /wwwroot/conf/httpd/$hostname.conf
echo "<VirtualHost *>" >> /wwwroot/conf/httpd/$hostname.conf
echo "  ServerAdmin user at domain.co.za"
>> /wwwroot/conf/httpd/$hostname.conf
echo "  DocumentRoot /wwwroot/webapps/$hostname/web/"
>> /wwwroot/conf/httpd/$hostname.conf
echo "  ServerName $hostname" >> /wwwroot/conf/httpd/$hostname.conf
echo "  ServerAlias $hostname" >> /wwwroot/conf/httpd/$hostname.conf
echo "  ErrorLog /var/log/httpd/$hostname""_error_log"
>> /wwwroot/conf/httpd/$hostname.conf
echo "  CustomLog /var/log/httpd/$hostname""_access_log combined"
>> /wwwroot/conf/httpd/$hostname.conf
echo "</VirtualHost>" >> /wwwroot/conf/httpd/$hostname.conf

echo "<html>" >> /wwwroot/webapps/$hostname/web/index.html
echo "<head><title>$hostname</title></head>"
>> /wwwroot/webapps/$hostname/web/index.html
echo "<body>" >> /wwwroot/webapps/$hostname/web/index.html
echo "<h1>$hostname</h1>" >> /wwwroot/webapps/$hostname/web/index.html
echo "</body>" >> /wwwroot/webapps/$hostname/web/index.html
echo "</html>" >> /wwwroot/webapps/$hostname/web/index.html





More information about the clug-chat mailing list