Skip to content

Instantly share code, notes, and snippets.

@ianlintner-wf
Created March 24, 2014 17:49
Show Gist options
  • Select an option

  • Save ianlintner-wf/9745407 to your computer and use it in GitHub Desktop.

Select an option

Save ianlintner-wf/9745407 to your computer and use it in GitHub Desktop.
Create a ideal vhost for drupal via shell script. Customize for your site / var web directory.
#!/usr/bin/env bash
tmpfile=/tmp/vhostfile
vhost=/etc/apache2/sites-available/$1
echo "creating $vhost for directory /var/sites/$2"
echo "<VirtualHost *:80>" > $tmpfile
echo " DocumentRoot /var/sites/$2" >> $tmpfile
echo " ServerName $1" >> $tmpfile
echo " RewriteEngine On" >> $tmpfile
echo " RewriteOptions inherit" >> $tmpfile
echo " CustomLog /var/log/apache2/$1.log combined" >> $tmpfile
echo "</VirtualHost>" >> $tmpfile
cp $tmpfile $vhost
a2ensite $1
service apache2 reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment