Skip to content

Instantly share code, notes, and snippets.

@durvalrafael
Created December 14, 2015 12:10
Show Gist options
  • Select an option

  • Save durvalrafael/7b1d20f2b564306f183f to your computer and use it in GitHub Desktop.

Select an option

Save durvalrafael/7b1d20f2b564306f183f to your computer and use it in GitHub Desktop.
echo "Server name :"
read vhost
echo "Main path (Ex.: /var/www/example) :"
read path
echo "Creating VHost configuration"
echo "<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName $vhost
ServerAlias www.$vhost
DocumentRoot /var/www/$path
<Directory /var/www/$path>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>" > /etc/apache2/sites-available/$vhost.conf
echo "Enabling VHOST $vhost"
a2ensite $vhost.conf
echo "Updating hosts"
echo "127.0.1.1 $vhost www.$vhost" >> /etc/hosts
echo "Restarting apache";
service apache2 restart
echo "VHOST created ";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment