Skip to content

Instantly share code, notes, and snippets.

@markatom
Created March 3, 2015 13:23
Show Gist options
  • Save markatom/b984660d4833786e19e9 to your computer and use it in GitHub Desktop.
Save markatom/b984660d4833786e19e9 to your computer and use it in GitHub Desktop.
Create virtual host
#!/bin/bash
if [ -z $1 ]; then
echo Usage: $0 project-name >&2
exit 1
fi
CONFIG=$(cat << 'END'
<VirtualHost *:80>
ServerName %name%.dev
ServerAlias www.%name%.dev
DocumentRoot /var/www/%name%/www
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/%name%>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
END
)
CONFIG=${CONFIG//%name%/$1}
echo "$CONFIG" > "/etc/apache2/sites-available/$1.conf"
a2ensite "$1.conf"
service apache2 reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment