Last active
December 5, 2021 23:03
-
-
Save DragonBe/7053b9937d64cf08f73034907f249589 to your computer and use it in GitHub Desktop.
Quickly run PHP 7.2, MySQL 5.7 and Nginx 1.14 within Vagrant
This file contains 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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.require_version ">= 2.2.0" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vagrant.plugins = ["vagrant-vbguest"] | |
config.vm.define "devbox", primary: true do | devbox | | |
devbox.vm.box = "debian/stretch64" | |
devbox.vm.host_name = "devbox" | |
devbox.vm.box_check_update = true | |
devbox.vm.network "private_network", ip: "192.168.101.202" | |
devbox.vm.synced_folder "./", "/vagrant", type: "virtualbox", owner: "vagrant", group: "vagrant" | |
devbox.vm.provider "virtualbox" do |vb| | |
vb.customize ["modifyvm", :id, "--memory", "4096"] | |
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] | |
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] | |
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"] | |
end | |
devbox.vm.provision "shell", inline: <<-SCRIPT | |
# General requirements | |
export DEBIAN_FRONTEND=noninteractive | |
apt-get update | |
apt-get install -y \ | |
curl \ | |
apt-transport-https \ | |
lsb-release \ | |
ca-certificates \ | |
zip \ | |
unzip | |
# PHP installation | |
curl -sSLo /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg | |
sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' | |
apt-get update | |
apt-get install -y \ | |
php7.2 \ | |
php7.2-bcmath \ | |
php7.2-bz2 \ | |
php7.2-cli \ | |
php7.2-common \ | |
php7.2-curl \ | |
php7.2-fpm \ | |
php7.2-gd \ | |
php7.2-intl \ | |
php7.2-json \ | |
php7.2-mbstring \ | |
php7.2-mysql \ | |
php7.2-opcache \ | |
php7.2-readline \ | |
php7.2-soap \ | |
php7.2-tidy \ | |
php7.2-xml \ | |
php7.2-xmlrpc \ | |
php7.2-xsl \ | |
php7.2-zip | |
# Nginx install | |
curl -fsSL https://nginx.org/keys/nginx_signing.key | apt-key add - | |
sh -c 'echo "deb http://nginx.org/packages/debian $(lsb_release -cs) nginx" > /etc/apt/sources.list.d/nginx.list' | |
apt-get update | |
apt-get install -y nginx | |
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/bin --filename=composer | |
# Setting up PHP FPM with Nginx | |
echo 'listen.owner = nginx' >> /etc/php/7.2/fpm/pool.d/www.conf | |
echo 'listen.group = nginx' >> /etc/php/7.2/fpm/pool.d/www.conf | |
service php7.2-fpm restart | |
# MySQL Installation | |
apt-get install -y \ | |
debconf \ | |
libaio1 | |
debconf-set-selections <<< 'mysql-apt-config mysql-apt-config/enable-repo select mysql-5.7' | |
debconf-set-selections <<< 'mysql-apt-config mysql-apt-config/select-server select mysql-5.7' | |
debconf-set-selections <<< 'mysql-server mysql-server/root_password password toor' | |
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password toor' | |
curl -sSLO https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb | |
dpkg -i mysql-apt-config_0.8.12-1_all.deb | |
apt-get update | |
apt-get install -y mysql-server | |
SCRIPT | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment