Created
March 3, 2015 13:23
Create virtual host
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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