Last active
December 25, 2015 14:29
-
-
Save luigimolinaro/6991145 to your computer and use it in GitHub Desktop.
Script bash able to create, in an easy way, a website for Apache
It wotks with debian/Ubuntu
This file contains 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
#!/bin/bash | |
echo "Inserisci il dominio (es: example.com):"; | |
read domain; | |
echo "" | |
echo "Inserisci l'Alias (es: www.example.com):"; | |
read domain_alias; | |
echo "" | |
### Check $domain esiste | |
if ! grep "${domain}" /etc/apache2/sites-available/${domain}.conf >> /dev/null; then | |
echo "${domain} will be created" | |
mkdir -p /var/www/${domain}/{htdocs,logs,cgi-bin}; fi | |
echo " | |
<VirtualHost *:80> | |
ServerName ${domain} | |
ServerAlias ${domain_alias} | |
DocumentRoot /var/www/${domain}/htdocs | |
ServerAdmin tech@neen.it | |
<Files ~ "^\.|\/\."> | |
Order allow,deny | |
Deny from all | |
</Files> | |
ErrorLog /var/www/${domain}/logs/error.log | |
CustomLog /var/www/${domain}/logs/access.log combined | |
</VirtualHost>" >> /etc/apache2/sites-available/${domain}.conf | |
echo "Testing configuration" | |
/etc/init.d/apache2 configtest | |
a2ensite ${domain}.conf | |
/etc/init.d/apache2 reload | |
fi | |
fi | |
else | |
echo "${domain} Dominio già esistente" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment