Skip to content

Instantly share code, notes, and snippets.

@normeno
Created October 1, 2018 14:45
Show Gist options
  • Save normeno/ce639c6623030bb23ca5100c73499647 to your computer and use it in GitHub Desktop.
Save normeno/ce639c6623030bb23ca5100c73499647 to your computer and use it in GitHub Desktop.
Vagrant Bootstrappers
#!/usr/bin/env bash
echo "Starting Bootstrap"
# Add PPA
if ! grep -q "^deb .*ondrej/php" /etc/apt/sources.list /etc/apt/sources.list.d/*; then
sudo add-apt-repository ppa:ondrej/php
else
echo "ondrej/php is already added"
fi
# Update System
apt-get update
# Install Apache
if [ $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
apt-get install -y apache2
rm -rf /var/www
ln -fs /vagrant /var/www
else
echo "the package \"apache2\" is already installed"
fi
# Install PHP7.2
if [ $(dpkg-query -W -f='${Status}' php7.2 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
sudo apt-get install php7.2 libapache2-mod-php7.2 -y
else
echo "the package \"php7.2\" & \"libapache2-mod-php7.2\" is already installed"
fi
# Restart Apache
sudo /etc/init.d/apache2 restart
# Configure Apache
echo "ServerName localhost" | sudo tee /etc/apache2/sites-available/fqdn.conf
sudo unlink /etc/apache2/sites-enabled/fqdn.conf
sudo ln -s /etc/apache2/sites-available/fqdn.conf /etc/apache2/sites-enabled/fqdn.conf
# Restart Apache
sudo /etc/init.d/apache2 restart
echo "Bootstrap Finished"
@normeno
Copy link
Author

normeno commented Oct 1, 2018

Add config.vm.provision "shell", path: "./bootstrap.sh" to Vagrantfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment