trey (owner)

Forks

Revisions

gist: 73578 Download_button fork
public
Description:
Create virtual hosts with `sudo vhost site-name`. By Jason Tan.
Public Clone URL: git://gist.github.com/73578.git
Embed All Files: show embed
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
#!/bin/sh
 
ME=your-username
DIR=/Users/$ME/Sites/$1
if [ ! -d $DIR ]
    then
sudo -u $ME mkdir $DIR
    sudo -u $ME touch $DIR/index.php
    echo "<h1>$1</h1>" >> $DIR/index.php
fi
 
VHOST=/etc/apache2/extra/httpd-vhosts.conf
echo "\n<VirtualHost *:80>" >> $VHOST
echo "\tDocumentRoot \"$DIR\"" >> $VHOST
echo "\tServerName $1.dev" >> $VHOST
echo "</VirtualHost>\n" >> $VHOST
 
echo "127.0.0.1\t$1.dev" >> /etc/hosts
 
apachectl graceful
 
mate $DIR