Created
November 10, 2009 17:36
-
-
Save markuswustenberg/231062 to your computer and use it in GitHub Desktop.
This is a nice little script for setting up my vhosts.
This file contains 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 | |
# | |
# This is a nice little script for setting up my vhosts. | |
# I edited it to my needs from the original. Thanks to http://commandlineidiot.com | |
# | |
# ======================= | |
# Siteup Script 0.1 | |
# Written by Command Line Idiot | |
# http://commandlineidiot.com | |
# You may use, modify, and redistribute this script freely | |
# Released: August 2007 | |
# ======================= | |
# ======================= | |
# set functions | |
# ======================= | |
# make_vhost is the function to create a config file that | |
# Apache2 can interpret. The variable for the domain name is passed | |
# into the file at $dname, and the system-wide variable for username | |
# is passed into the file at $USER. You may wish to replace the | |
# ServerAdmin email address with your own email address. You may alter | |
# any of the code between the terms _EOF_ to build your own preferred | |
# standard config file. | |
function make_vhost | |
{ | |
cat <<- _EOF_ | |
<VirtualHost *:80> | |
ServerAdmin webmaster@${dname} | |
ServerName www.${dname} | |
DirectoryIndex index.htm index.php | |
DocumentRoot /var/www/vhosts/${dname}/www/public/ | |
<Directory /var/www/vhosts/${dname}/www/public/> | |
Options Indexes FollowSymLinks MultiViews | |
AllowOverride All | |
Order allow,deny | |
Allow from all | |
</Directory> | |
ErrorLog /var/www/log/${dname}_error.log | |
CustomLog /var/www/log/${dname}_access.log combined | |
</VirtualHost> | |
<VirtualHost *:80> | |
ServerName ${dname} | |
RedirectMatch permanent ^/(.*)$ http://www.${dname}/\$1 | |
</VirtualHost> | |
_EOF_ | |
} | |
# ======================= | |
# header | |
# ======================= | |
clear | |
echo "*** Site Setup ***" | |
# ======================= | |
# set domain name variable | |
# ======================= | |
echo -n "==> Enter new domain name (domain.com): " | |
read dname | |
echo "Setting up files for ${dname}" | |
mkdir -p /var/www/vhosts/${dname}/www/public | |
echo "created /var/www/vhosts/${dname}/www/public" | |
# ======================= | |
# build vhost config file | |
# ======================= | |
make_vhost > /etc/apache2/sites-available/${dname} | |
echo "created /etc/apache2/sites-available/${dname}" | |
# ======================= | |
# exit | |
# ======================= | |
echo "*** Finished setting up files for ${dname}." | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment