Created
December 28, 2011 12:35
-
-
Save jess/1527807 to your computer and use it in GitHub Desktop.
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
# This is a script I use to create a virtual host on my development Ubuntu machine | |
class VH | |
def self.create(domain, location) | |
dev = domain.split(".").insert(1, "dev").join(".") | |
if location.nil? | |
doc_root = "DocumentRoot /home/jess/virtual/#{domain}" | |
else | |
doc_root = "DocumentRoot #{location}" | |
end | |
host = " | |
<VirtualHost *:80> | |
ServerName #{domain} | |
ServerAlias #{dev} | |
#{doc_root} | |
</VirtualHost>" | |
File.open('/etc/apache2/sites-available/' + domain, 'w') {|f| f.write(host) } | |
cmd = "a2ensite #{domain}; /etc/init.d/apache2 reload" | |
%x[#{cmd}] | |
end | |
end | |
while(true) | |
print 'Enter [Domain] [Location]> ' | |
input = gets.split | |
domain = input[0] | |
location = input[1] unless input[1].nil? | |
unless domain=="" | |
exit if domain=="exit" || domain=="quit" | |
d = VH.create(domain, location) | |
puts "Virtual Host for #{domain} created (remember to restart apache rails env dev?)" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment