Skip to content

Instantly share code, notes, and snippets.

@chrisenytc
Created August 23, 2013 00:34
Show Gist options
  • Save chrisenytc/6314356 to your computer and use it in GitHub Desktop.
Save chrisenytc/6314356 to your computer and use it in GitHub Desktop.
Script to Create Apache vHosts
#!/bin/bash
echo "Informe o nome do server (Ex.: project.dev) :"
read server
echo "Informe o caminho do site (Ex.: /var/www/project-directory) :"
read path
echo "Criando configuração de VHost para o server"
echo "
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName $server
ServerAlias www.$server
DocumentRoot "$path"
<Directory "$path">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
" > /etc/apache2/sites-available/$server
echo "Ativando VHOST $server"
ln -s /etc/apache2/sites-available/$server /etc/apache2/sites-enabled/$server
echo "Atualizando arquivo hosts"
echo "127.0.1.1 $server www.$server" >> /etc/hosts
echo "Reiniciando apache";
/etc/init.d/apache2 restart
echo "VHOST criado sucesso.";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment