Created
November 28, 2016 12:55
-
-
Save eduardoaugustojulio/8d82754e2828a0ec5e351dab86b3f893 to your computer and use it in GitHub Desktop.
apache virtual host creator
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 | |
# Este programa cria uma virtual host e sua pagina de apresentação | |
# OBS: OS HOSTS CRIADOS TERAO NOME FINAL .COM.BR | |
# Utilizicao | |
# sudo ./apache_creator.sh app porta 8383 | |
# ou | |
# sudo ./apache_creator.sh | |
www=/var/www/html/ | |
app=$1 | |
port=$3 | |
if [ "$(whoami)" != 'root' ]; then | |
echo "Use sudo para executar $0." | |
exit 1; | |
fi | |
if [ $# -neq 3 ]; then | |
echo "Entre com o nome do app: " | |
read app | |
echo "Entre com o numero da porta: " | |
read port | |
fi | |
echo "<html> | |
<head> | |
<title>Welcome to $app.com.br!</title> | |
</head> | |
<body> | |
<h1>Success! The $app.com.br! virtual host is working!</h1> | |
</body> | |
</html>" > $www$app/public_html/index.html | |
echo "<VirtualHost *:$port> | |
DocumentRoot $www$app.com.br | |
ServerName $app.com.br | |
ServerAlias www.$app.com.br | |
ErrorLog ${APACHE_LOG_DIR}/error.log | |
CustomLog ${APACHE_LOG_DIR}/access.log combined | |
</VirtualHost>" > /etc/apache2/sites-available/$app.conf | |
#adiciona host | |
#echo 127.0.0.1 $app.com.br >> /etc/hosts | |
# Habilita no apache | |
a2ensite $app | |
etc/init.d/apache2 restart | |
echo "novo host disponivel em http://$app.com.br" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment