Skip to content

Instantly share code, notes, and snippets.

@kybernetyk
Created May 29, 2011 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kybernetyk/997614 to your computer and use it in GitHub Desktop.
Save kybernetyk/997614 to your computer and use it in GitHub Desktop.
create directory + append entry to vhosts.conf
#!/bin/bash
if [ "$2" = "" ]; then
echo "syntax: newhost <domainname> <dirname>";
exit 1;
fi
echo "domain: $1";
echo "dir: $2";
echo "#domain $1 - dir $2" > http.tmp
echo "<VirtualHost *:80>" >> http.tmp;
echo " DocumentRoot /var/www/$2" >> http.tmp;
echo " ServerName www.$1" >> http.tmp;
echo " ServerAlias $1" >> http.tmp;
echo " ErrorLog /var/www/$2/logs/error_log" >> http.tmp;
echo " CustomLog /var/www/$2/logs/access_log combined" >> http.tmp;
echo " CustomLog /var/www/$2/logs/referer_log referer" >> http.tmp;
echo " " >> http.tmp;
echo " <Directory \"/var/www/$2\">" >> http.tmp;
echo " AllowOverride All" >> http.tmp;
echo " Options +FollowSymlinks" >> http.tmp;
echo " Order allow,deny" >> http.tmp;
echo " Allow from all" >> http.tmp;
echo " </Directory>" >> http.tmp;
echo "</VirtualHost>" >> http.tmp;
echo " " >> http.tmp;
echo " " >> http.tmp;
mkdir $2
mkdir $2/logs
cat http.tmp >> vhosts.conf
rm http.tmp
#/opt/lampp/lampp restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment