jan_flanders

Untitled

Jul 3rd, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. if [ "$1" == "" ]
  3. then
  4. echo "No subdomain given"
  5. else
  6. echo "Creating subdomain $1"
  7. sudo mkdir -p "/home/adnez/subdomains/$1"
  8. sudo echo "<html><body>$1</body></html>" > "/home/adnez/subdomains/$1/index.html"
  9. sudo chown "adnez.adnez" "/home/adnez/subdomains/$1" -Rf
  10.  
  11. sudo echo "<VirtualHost *:80>
  12. ServerAdmin webmaster@localhost
  13. ServerName $1
  14. ServerAlias www.$1
  15.  
  16. DocumentRoot /home/adnez/subdomains/$1
  17.  
  18. <Directory />
  19. Options FollowSymLinks
  20. AllowOverride All
  21. </Directory>
  22. <Directory /home/adnez/subdomains/$1>
  23. Options Indexes FollowSymLinks MultiViews
  24. AllowOverride All
  25. Order allow,deny
  26. allow from all
  27. </Directory>
  28.  
  29. ErrorLog /var/log/apache2/$1.error.log
  30.  
  31. # Possible values include: debug, info, notice, warn, error, crit,
  32. # alert, emerg.
  33. LogLevel warn
  34.  
  35. CustomLog /var/log/apache2/$1.access.log combined
  36.  
  37. </VirtualHost>" > "/etc/apache2/sites-available/$1.conf"
  38. sudo a2ensite "$1.conf"
  39. sudo /etc/init.d/apache2 reload
  40. fi
Advertisement
Add Comment
Please, Sign In to add comment