#!/bin/bash ## MakeVHost Script ## Author: Ze'ev Schurmann ## Reddit: u/thisiszeev ## License: GPL-3.0 or later ## This script creates a vhost on a debian based server running Apache2. It assumes that ## the www path is /var/www/ and that the Apache2 logs are stored at /var/log/apache2/ ## To use it, either use ./makevhost.sh {domainname} or simple use ./makevhost.sh and it ## will ask you for the domain name. ## Requires certbot from Let's Encrypt ## Please consider making me small donation. Even though my scripts are open source and free to use, I still need to eat. And the ## occasional bottle of wine also goes down well. ## $5 buys me a cup of coffee ## $10 buys me a nice burger ## $20 buys me a bottle of wine ## Anything above that will be awesome as well. ## You can send me a donation via Paypal https://www.paypal.com/paypalme/thisiszeev ## Drop me a message on Reddit if you do make a donation. ## Support is only offered freely to those who donate $20 or more. ## Your donation contributes to further development. ## If you need a custom script, contact me on Reddit for pricing. if [[ -z $1 ]]; then echo -n "Enter domain to add to Apache2 server as vhost: " read domain else domain=$1 fi echo "Creating web folder at /var/www/$domain/" mkdir "/var/www/$domain" touch "/var/www/$domain/index.html" echo "
$domain is working!
" >> "/var/www/$domain/index.html" chown -R www-data:www-data "/var/www/$domain" echo "Creating log folder at /var/log/apache2/$domain/" mkdir "/var/log/apache2/$domain" chown -R root:adm "/var/log/apache2/$domain" echo "Configuring Apache2" touch "/etc/apache2/sites-available/$domain.conf" echo "