forked from renekopcem/wamp-vhost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vhost.sh
53 lines (42 loc) · 1017 Bytes
/
vhost.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh
# This script is based on https://github.com/MattSkala/apache-vhost script.
# A simple bash script that creates a virtual host in Apache on Windows Msysgit
# Usage: sh ./vhost.sh myweb.dev 'c:\Projects\myweb\www'
HOSTS=/c/Windows/System32/Drivers/etc/hosts
HTTPDCONF=/c/wamp/bin/apache/Apache2.4.4/conf/extra/httpd-vhosts.conf
# 2 arguments are required
if [ -o $1 ]
then
echo "You have to provide a domain name"
exit
fi
if [ -o $2 ]
then
echo "You have to provide a path"
exit
fi
if [ -o $3 ]
then
echo "You have to provide a description"
exit
fi
# Map domain to localhost in hosts file
echo -e "127.0.0.1 $1 #$3" >> $HOSTS
# Add virtual host to httpd.conf
echo "
# $1 Templates
<VirtualHost *:80>
ServerAdmin admin@localhost.com
DocumentRoot '$2'
ServerName $1
ServerAlias $1
<Directory '$2'>
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>" >> $HTTPDCONF
echo "$1 mapped to $2"
# Restart Apache
net stop wampapache
net start wampapache