Skip to content

Instantly share code, notes, and snippets.

@faisalarbain
Created March 4, 2014 05:48
Show Gist options
  • Save faisalarbain/9340940 to your computer and use it in GitHub Desktop.
Save faisalarbain/9340940 to your computer and use it in GitHub Desktop.
Snippet to setup apache and VHOST for Vagrant Provisioner
# Apache
# ------
# Install
apt-get install -y apache2
# Remove /var/www default
rm -rf /var/www
# Symlink /vagrant to /var/www
ln -fs /vagrant /var/www
# Add ServerName to httpd.conf
echo "ServerName localhost" > /etc/apache2/httpd.conf
# Setup hosts file
VHOST=$(cat <<EOF
<VirtualHost *:80>
DocumentRoot "/vagrant/public"
ServerName localhost
<Directory "/vagrant/public">
AllowOverride All
</Directory>
</VirtualHost>
EOF
)
echo "${VHOST}" > /etc/apache2/sites-enabled/000-default
# Enable mod_rewrite
a2enmod rewrite
# Restart apache
service apache2 restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment