Скрипт автоматического создания виртуальных хостов

Скрипт предназначен только для localhost!
Надоело все ручками прописывать. Вот скрипт, актуален для OpenSuse 12.1:

#!/bin/sh
echo "<VirtualHost *:80>
  ServerAdmin 1@royaldt.dev
        ServerName $1
        DocumentRoot /srv/www/htdocs/$1
        ErrorLog  /srv/www/htdocs/$1/error_log
        CustomLog  /srv/www/htdocs/$1/access_log combined    
        <Directory /srv/www/htdocs/$1/>
            Options None
            AllowOverride All
            Order deny,allow
            Allow from all
        </Directory>
</VirtualHost>"
> /etc/apache2/vhosts.d/$1.conf

echo "Created $1.conf in /etc/apache2/vhosts.d/"

echo 127.0.0.1  $1 >> /etc/hosts

echo "Added Alias 127.0.0.1 $1 into /etc/hosts"

mkdir /srv/www/htdocs/$1

echo "Created directory /srv/www/htdocs/$1"

chmod 777 /srv/www/htdocs/$1

echo "Warning! Chmod 777! For site dir."

echo "<h1>$1</h1>" > /srv/www/htdocs/$1/index.html

echo "Created default html file"

#my access for mysql root:root
/usr/bin/mysql -uroot -proot mysql -e "CREATE DATABASE IF NOT EXISTS $1;"

echo "Created database $1"

/etc/init.d/apache2 reload

echo "Your site has ready http://$1/"

Запуск от рута, первый параметр это имя хоста:

#sh ./addNewSite tsjee

Под ubuntu 11.10

#!/bin/sh
echo "<VirtualHost *:80>
        ServerAdmin 1@royaldt.dev
        ServerName $1
        DocumentRoot /var/www/$1
        ErrorLog  /var/www/$1/error_log
        CustomLog  /var/www/$1/access_log combined    
        <Directory /var/www/$1/>
            Options None
            AllowOverride All
            Order deny,allow
            Allow from all
        </Directory>
</VirtualHost>"
> /etc/apache2/sites-available/$1.conf

echo "Created $1.conf in /etc/apache2/sites-available/"

echo 127.0.0.1  $1 >> /etc/hosts

echo "Added Alias 127.0.0.1 $1 into /etc/hosts"

mkdir /var/www/$1

echo "Created directory /var/www/$1"

/usr/bin/mysql -uroot -proot mysql -e "CREATE DATABASE IF NOT EXISTS $1;"

echo "Created database $1"

/usr/sbin/a2ensite $1.conf

/etc/init.d/apache2 reload

echo "Your site has ready http://$1/"

UPD: Debian 7

#!/bin/sh
echo "<VirtualHost *:80>
    ServerAdmin 1@royaldt.dev
    ServerName $1
    DocumentRoot /var/www/$1
    ErrorLog logs/$1.error
    CustomLog logs/$1 common
    <Directory /var/www/$1/>
    Options None
    AllowOverride All
    Order deny,allow
    Allow from all
    </Directory>
</VirtualHost>"
> /etc/apache2/vhosts/$1.conf
echo  "Created $1.conf in /etc/apache2/vhosts/"
echo 127.0.0.1  $1 >> /etc/hosts

echo "Added Alias 127.0.0.1 $1 into /etc/hosts"

mkdir /var/www/$1

echo "Created directory /var/www/$1"

/usr/bin/mysql -uroot -proot mysql -e "CREATE DATABASE IF NOT EXISTS $1;"

echo "Created database $1"
/etc/init.d/apache2 restart
echo "Your site has ready http://$1/"

echo "<h1>Hello World!</h1>" > /var/www/$1/index.html