Skip to content

Instantly share code, notes, and snippets.

@araeuchle
Created December 3, 2017 15:23
Show Gist options
  • Save araeuchle/e8edfc2975890d330003f6f7923c3b44 to your computer and use it in GitHub Desktop.
Save araeuchle/e8edfc2975890d330003f6f7923c3b44 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
sudo apt-get update
sudo apt-get install -y apache2
# create the html dir if its not present
if ! [ -L /var/www/html ]; then
rm -rf /var/www/html
ln -fs /vagrant /var/www/html
fi
# enable mod rewrite and restart apache
sudo a2enmod rewrite
sudo service apache2 start
# this is needed to avoid password prompt on mysql installation
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password secret'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password secret'
sudo apt-get install -y mysql-server
# install php 7.2 and desired extensions
# needed for symfony are xml, curl and zip then restart apache
sudo apt-get install -y python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php7.2 php7.2-xml php7.2-curl php7.2-zip
sudo service apache2 restart
# used to install composer via curl
sudo apt-get install -y curl
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
sudo apt-get install -y zip
# configure the webserver
WEBROOT="/var/www/html"
VHOSTDIR="/etc/apache2/sites-available/"
RESTARTCMD="/usr/bin/sudo service apache2 reload"
VHOSTCONFIG="/vagrant/configs/skeleton"
PROJECTNAME="bfs.dev"
if ! [ -f "$VHOSTDIR$PROJECTNAME" ]
then
cp "$VHOSTCONFIG" "$VHOSTDIR/$PROJECTNAME.conf"
fi
sudo a2ensite $PROJECTNAME
$RESTARTCMD
# install nodejs and npm
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
# install yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install -y yarn
# install webpack
cd $WEBROOT
yarn add @symfony/webpack-encore --dev
# Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "geerlingguy/ubuntu1604"
config.vm.provision :shell, path: "configs/bootstrap.sh"
config.vm.network :private_network, ip: "222.222.222.222"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment