Create new Apache VirtualHost files and /var/www directories


/ Published in: Bash
Save to your folder(s)

Fairly self-explanator, but:

Expects a directory at <code>/var/www/skeleton</code> with the correct permissions. This is then copied and renamed. Also expects a file named <code>/etc/apache2/sites-available/skeleton</code> which is used to copy the VirtualHost configuration.


Copy this code and paste it in your HTML
  1. #!/bin/sh
  2.  
  3. if [ -z "$1" ]; then
  4. echo "Usage: a2mksite <DOMAIN>"
  5. echo ""
  6. echo "Please supply a domain name"
  7. exit 0
  8. fi
  9.  
  10. cp -R "/var/www/skeleton" "/var/www/$1"
  11. sed -e "s/skeleton/$1/g" "/etc/apache2/sites-available/skeleton" > "/etc/apache2/sites-available/$1.dev"
  12. a2ensite "$1.dev"

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.