Skip to content

Instantly share code, notes, and snippets.

@easterncoder
Last active August 17, 2020 05:25
Show Gist options
  • Save easterncoder/a0a077fea9e120e2281a7c6c416088d1 to your computer and use it in GitHub Desktop.
Save easterncoder/a0a077fea9e120e2281a7c6c416088d1 to your computer and use it in GitHub Desktop.
Ubuntu Focal Fossa LAMP Stack
Vagrant.configure("2") do |config|
# we use the generic ubuntu 20.04 box
config.vm.box = "generic/ubuntu2004"
# set the local hostname to myapp.local
# you may change this to whatever you like but it's best to keep the .local part
config.vm.hostname = 'myapp.local'
# sync folders
config.vm.allowed_synced_folder_types = [:nfs, :smb, :sshfs, :rsync]
config.vm.synced_folder ".", "/vagrant", nfs_version: 4
config.vm.synced_folder "./app", "/var/www/html", create: true, nfs_version: 4
# install php, mysql and apache
config.vm.provision "shell", inline: "apt-get -y update; apt-get -y install libapache2-mod-php php-mysql mysql-server"
# setup zeroconf so we can access the vm using the hostname specified above
config.vm.provision "shell", inline: "apt-get install -y avahi-daemon libnss-mdns"
# set mysql root password to 'root' and do a few more things
config.vm.provision "shell", inline: <<-SHELL
mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'; DELETE FROM mysql.user WHERE User=''; DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1'); DROP DATABASE IF EXISTS test; DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'; FLUSH PRIVILEGES;" || echo ""
SHELL
# download adminer.php and create phpinfo.php
config.vm.provision "shell", inline: <<-SHELL
wget -q adminer.org/latest-mysql-en.php -O /var/www/html/adminer.php
echo '<?php phpinfo(); ?>' > /var/www/html/phpinfo.php
SHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment