Skip to content

Instantly share code, notes, and snippets.

@p8R
Forked from faisalarbain/gist:9340940
Created August 16, 2018 12:20
Show Gist options
  • Save p8R/d67caaceca23692500ccc2c0763dc694 to your computer and use it in GitHub Desktop.
Save p8R/d67caaceca23692500ccc2c0763dc694 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