Last active
April 6, 2020 04:14
-
-
Save havran/8b509c7c2c53c63f6ecf54c348494b8d to your computer and use it in GitHub Desktop.
Vagrantfile -> Ubuntu 16.04 / PHP 5.6/7.1/7.2 / Nginx / MySQL (MariaDB)
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 : | |
# All Vagrant configuration is done below. The "2" in Vagrant.configure | |
# configures the configuration version (we support older styles for | |
# backwards compatibility). Please don't change it unless you know what | |
# you're doing. | |
Vagrant.configure("2") do |config| | |
# The most common configuration options are documented and commented below. | |
# For a complete reference, please see the online documentation at | |
# https://docs.vagrantup.com. | |
# Every Vagrant development environment requires a box. You can search for | |
# boxes at https://vagrantcloud.com/search. | |
config.vm.box = "geerlingguy/ubuntu1604" | |
config.vm.define "LAMP" do |n| | |
end | |
# Disable automatic box update checking. If you disable this, then | |
# boxes will only be checked for updates when the user runs | |
# `vagrant box outdated`. This is not recommended. | |
# config.vm.box_check_update = false | |
# Create a forwarded port mapping which allows access to a specific port | |
# within the machine from a port on the host machine. In the example below, | |
# accessing "localhost:8080" will access port 80 on the guest machine. | |
# NOTE: This will enable public access to the opened port | |
config.vm.network "forwarded_port", guest: 80, host: 80, auto_correct: true, host_ip: "127.0.0.1" # HTTP | |
config.vm.network "forwarded_port", guest: 8000, host: 8000, auto_correct: true, host_ip: "127.0.0.1" # HTTP (Symfony server) | |
config.vm.network "forwarded_port", guest: 3306, host: 3306, auto_correct: true, host_ip: "127.0.0.1" # MySQL | |
config.vm.network "forwarded_port", guest: 4200, host: 4200, auto_correct: true, host_ip: "127.0.0.1" # Angular Server | |
config.vm.network "forwarded_port", guest: 5432, host: 5432, auto_correct: true, host_ip: "127.0.0.1" # PostgreSQL | |
config.vm.network "forwarded_port", guest: 9200, host: 9200, auto_correct: true, host_ip: "127.0.0.1" # Elasticseach | |
config.vm.network "forwarded_port", guest: 27017, host: 27017, auto_correct: true, host_ip: "127.0.0.1" # MongoDB | |
# Create a forwarded port mapping which allows access to a specific port | |
# within the machine from a port on the host machine and only allow access | |
# via 127.0.0.1 to disable public access | |
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" | |
# Create a private network, which allows host-only access to the machine | |
# using a specific IP | |
config.vm.network "private_network", ip: "192.168.33.10" | |
config.vm.hostname = "lamp.local" | |
config.hostsupdater.aliases = [ | |
"adminer", "adminer.local", | |
"example.com.lamp.local" | |
] | |
# Create a public network, which generally matched to bridged network. | |
# Bridged networks make the machine appear as another physical device on | |
# your network. | |
# config.vm.network "public_network" | |
# Share an additional folder to the guest VM. The first argument is | |
# the path on the host to the actual folder. The second argument is | |
# the path on the guest to mount the folder. And the optional third | |
# argument is a set of non-required options. | |
# config.vm.synced_folder "../data", "/vagrant_data" | |
# Provider-specific configuration so you can fine-tune various | |
# backing providers for Vagrant. These expose provider-specific options. | |
# Example for VirtualBox: | |
# | |
config.vm.provider "virtualbox" do |vb| | |
# Display the VirtualBox GUI when booting the machine | |
vb.gui = false | |
vb.name = "LAMP" | |
# Customize the amount of memory on the VM: | |
vb.memory = "2048" | |
vb.cpus = 4 | |
end | |
# View the documentation for the provider you are using for more | |
# information on available options. | |
# Enable provisioning with a shell script. Additional provisioners such as | |
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the | |
# documentation for more information about their specific syntax and use. | |
config.vm.provision "main", type: "shell", inline: <<-SHELL | |
apt -y update | |
# DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade | |
# Basic tools | |
apt -y install htop mc git git-core tig screen | |
# Build tools | |
apt -y install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev | |
# SAMBA | |
apt -y install samba | |
echo >> /etc/samba/smb.conf | |
echo '[data]' >> /etc/samba/smb.conf | |
echo ' comment = Data directory' >> /etc/samba/smb.conf | |
echo ' path = /data' >> /etc/samba/smb.conf | |
echo ' writeable = yes' >> /etc/samba/smb.conf | |
echo ' create mask = 0644' >> /etc/samba/smb.conf | |
echo ' directory mas = 0755' >> /etc/samba/smb.conf | |
echo ' valid users = vagrant root' >> /etc/samba/smb.conf | |
echo ' oplocks = False' >> /etc/samba/smb.conf | |
echo ' level2 oplocks = False' >> /etc/samba/smb.conf | |
echo ' dos filetime resolution = yes' >> /etc/samba/smb.conf | |
echo ' force user = vagrant' >> /etc/samba/smb.conf | |
echo ' force group = vagrant' >> /etc/samba/smb.conf | |
echo >> /etc/samba/smb.conf | |
# Add directories and samba user vagrant with password vagrant. | |
mkdir /data | |
chown -R vagrant:vagrant /data | |
(echo vagrant; echo vagrant) | smbpasswd -a vagrant -s | |
service smdb restart | |
# add locale sk_SK and sk_SK.UTF-8 | |
locale-gen sk_SK | |
locale-gen sk_SK.UTF-8 | |
# Remove unuswd packages | |
apt autoremove -y | |
SHELL | |
config.vm.provision "php", type: "shell", inline: <<-SHELL | |
# PHP | |
add-apt-repository -y ppa:ondrej/php | |
apt -y update | |
# PHP 5.6 | |
apt install -y php5.6 php5.6-cli php5.6-fpm php5.6-curl php5.6-gd php5.6-mcrypt php5.6-mbstring php5.6-mysql php5.6-xml php5.6-bcmath | |
# PHP 7.1 | |
apt install -y php7.1 php7.1-cli php7.1-fpm php7.1-curl php7.1-gd php7.1-mcrypt php7.1-mbstring php7.1-mysql php7.1-xml php7.1-bcmath | |
# PHP 7.2 | |
apt install -y php7.2 php7.2-cli php7.2-fpm php7.2-curl php7.2-gd php7.2-mcrypt php7.2-mbstring php7.2-mysql php7.2-xml php7.2-bcmath | |
SHELL | |
config.vm.provision "nginx", type: "shell", inline: <<-SHELL | |
add-apt-repository -y ppa:ondrej/nginx | |
apt install -y nginx | |
SHELL | |
config.vm.provision "mysql", type: "shell", inline: <<-SHELL | |
apt-get install software-properties-common | |
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 | |
add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://www.ftp.saix.net/DB/mariadb/repo/10.1/ubuntu xenial main' | |
apt-get update -y | |
# MariaDB 10 | |
export DEBIAN_FRONTEND=noninteractive | |
debconf-set-selections <<< 'mariadb-server-10.0 mysql-server/root_password password root' | |
debconf-set-selections <<< 'mariadb-server-10.0 mysql-server/root_password_again password root' | |
apt-get install -y mariadb-server mariadb-client | |
SHELL | |
config.vm.provision "local", type: "shell", path: "provision/provision_local.sh" if File.exist?("provision/provision_local.sh") | |
# Use PuTTY | |
config.putty.ssh_client = "C:/My Programs/Tools/PuTTY/putty.exe" | |
config.ssh.forward_agent = true | |
config.putty.session = 'Default Settings' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment