Last active
December 19, 2023 06:04
-
-
Save Chris820/751e5a05229285d6b4093bf402187b5b to your computer and use it in GitHub Desktop.
My Vagrantfile. Creates a LAMP environment suitable for Drupal and Wordpress development.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vagrant.configure("2") do |config| | |
config.vm.box = "ubuntu/focal64" | |
config.vm.network "private_network", ip: "192.168.33.10" | |
config.vm.synced_folder "~/Documents/Sites", "/var/www/html", mount_options: ["dmode=777", "fmode=777"] | |
config.vm.synced_folder "~/vagrant-localdev/db-details", "/var/www/db-details" | |
config.vm.synced_folder "~/vagrant-localdev/configs", "/etc/apache2/sites-enabled" | |
config.vm.synced_folder "~/vagrant-localdev/logs", "/var/www/logs" | |
config.vm.synced_folder "~/vagrant-localdev/scripts", "/home/vagrant/scripts" | |
config.vm.synced_folder "~/Documents/Transfer", "/home/vagrant/transfer" | |
# Plenty of memory and CPU cores | |
config.vm.provider "virtualbox" do |v| | |
v.memory = 4096 | |
v.cpus = 4 | |
end | |
# Extra HDD space, requires 'vagrant plugin install vagrant-disksize' | |
config.disksize.size = '50GB' | |
# Do provisioning | |
config.vm.provision "shell", inline: <<-SHELL | |
# Update and Install Utils | |
export DEBIAN_FRONTEND=noninteractive | |
sudo apt-get update | |
apt-get install -y zip unzip | |
# Install Apache | |
apt-get install -y apache2 | |
# Install PHP | |
apt-get install -y php php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath | |
# Install MySQL | |
debconf-set-selections <<< 'mysql-server mysql-server/root_password password root' | |
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root' | |
sudo apt-get install -y mysql-server | |
# Tweak mods | |
sudo a2dismod mpm_event | |
sudo a2enmod actions mpm_prefork rewrite php7.4 | |
sudo phpenmod mbstring | |
# Install Composer | |
curl -sS https://getcomposer.org/installer | php | |
mv composer.phar /usr/local/bin/composer | |
# WP CLI | |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar | |
chmod +x wp-cli.phar | |
mv wp-cli.phar /usr/local/bin/wp | |
SHELL | |
# Always (re)Start Apache and MySQL | |
config.vm.provision "shell", run: "always", inline: "sudo service apache2 start" | |
config.vm.provision "shell", run: "always", inline: "sudo service mysql start" | |
config.vm.provision "shell", run: "always", inline: "sudo service apache2 restart" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment