Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- mode: ruby -*-
- # vi: set ft=ruby :
- require 'yaml'
- vagrantConfig = YAML.load_file 'Vagrantfile.config.yml'
- # 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 = "ubuntu/bionic64"
- # 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: 8080
- # 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: vagrantConfig['ip']
- # 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"
- # Mount local "~/www/B05032-Magento-Box/" path into box's "/vagrant-B05032-Magento-Box/" path
- config.vm.synced_folder vagrantConfig['synced_folder']['host_path'],vagrantConfig['synced_folder']['guest_path'], owner:"vagrant", group: "www-data", mount_options:["dmode=775,fmode=664"]
- # 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
- # Customize the amount of memory on the VM:
- vb.memory = "2048"
- # Customize CPUS
- vb.cpus = 2
- 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 "shell", inline: <<-SHELL
- # apt-get update
- # apt-get install -y apache2
- # SHELL
- #config.vm.provision "file", source: "~/.gitconfig", destination:".gitconfig"
- config.vm.provision "shell", inline: "sudo apt-get update"
- #Apache
- config.vm.provision "shell", inline: "sudo apt-get -y install apache2"
- config.vm.provision "shell", inline: "sudo update-rc.d apache2 defaults"
- config.vm.provision "shell", inline: "sudo service apache2 start"
- config.vm.provision "shell", inline: "sudo a2enmod rewrite"
- config.vm.provision "shell", inline: "sudo awk '/<Directory\\/>/,/AllowOverride None/{sub(\"None\", \"All\",$0)}{print}' /etc/apache2/apache2.conf > /tmp/tmp.apache2.conf"
- config.vm.provision "shell", inline: "sudo mv /tmp/tmp.apache2.conf /etc/apache2/apache2.conf"
- config.vm.provision "shell", inline: "sudo awk '/<Directory\\/var\\/www\\/>/,/AllowOverride None/{sub(\"None\", \"All\",$0)}{print}' /etc/apache2/apache2.conf > /tmp/tmp.apache2.conf"
- config.vm.provision "shell", inline: "sudo mv /tmp/tmp.apache2.conf /etc/apache2/apache2.conf"
- config.vm.provision "shell", inline: "sudo service apache2 stop"
- #PHP
- config.vm.provision "shell", inline: "sudo apt-get -y install php7.2-common php7.2-cli php7.2-fpm php7.2-opcache php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-xsl php7.2-mbstring php7.2-zip php7.2-bcmath php7.2-soap"
- config.vm.provision "shell", inline: "sudo apt install libapache2-mod-php7.2"
- config.vm.provision "shell", inline: "echo \"xdebug.max_nesting_level=200\">> /etc/php/7.2/apache2/php.ini"
- config.vm.provision "shell", inline: 'sudo sed -i "s/memory_limit = .*/memory_limit = 1024M/" /etc/php/7.2/apache2/php.ini'
- config.vm.provision "shell", inline: 'sudo sed -i "s/upload_max_filesize = .*/upload_max_filesize = 256M/" /etc/php/7.2/apache2/php.ini'
- config.vm.provision "shell", inline: 'sudo sed -i "s/zlib.output_compression = .*/zlib.output_compression = on/" /etc/php/7.2/apache2/php.ini'
- config.vm.provision "shell", inline: 'sudo sed -i "s/max_execution_time = .*/max_execution_time = 18000/" /etc/php/7.2/apache2/php.ini'
- config.vm.provision "shell", inline: 'sudo sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.2/apache2/php.ini'
- config.vm.provision "shell", inline: 'sudo sed -i "s/;opcache.save_comments.*/opcache.save_comments = 1/" /etc/php/7.2/apache2/php.ini'
- config.vm.provision "shell", inline: "sudo apt-get -y install phpunit"
- #MySQL
- config.vm.provision "shell", inline: "sudo debconf-set-selections <<<'mysql-server mysql-server/root_password password #{vagrantConfig['mysql']['password']}'"
- config.vm.provision "shell", inline: "sudo debconf-set-selections <<<'mysql-server mysql-server/root_password_again password #{vagrantConfig['mysql']['password']}'"
- config.vm.provision "shell", inline: "sudo apt-get -y install mysql-server"
- config.vm.provision "shell", inline: "sudo service mysql start"
- config.vm.provision "shell", inline: "sudo update-rc.d mysql defaults"
- #Magento
- config.vm.provision "shell", inline: "sudo rm -Rf /var/www/html"
- config.vm.provision "shell", inline: "sudo ln -s #{vagrantConfig['synced_folder']['guest_path']} /var/www/html"
- config.vm.provision "shell", inline: "curl -sS https://getcomposer.org/installer | php", privileged: false
- config.vm.provision "shell", inline: "mv composer.phar /usr/local/bin/composer", privileged: false
- config.vm.provision "shell", inline: "composer clearcache", privileged: false
- config.vm.provision "shell", inline: "composer -V", privileged: false
- config.vm.provision "shell", inline: "echo '{\"http-basic\":{\"repo.magento.com\": {\"username\": \"#{vagrantConfig ['http_basic']['repo_magento_com']['username']}\",\"password\": \"#{vagrantConfig['http_basic']['repo_magento_com']['password']}\"}},\"github-oauth\": {\"github.com\": \"#{vagrantConfig['github_oauth']['github_com']}\"}}' >> /root/.composer/auth.json"
- config.vm.provision "shell", inline: "composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition /var/www/html/"
- config.vm.provision "shell", inline: "sudo mysql --user=#{vagrantConfig['mysql']['username']} --password=#{vagrantConfig['mysql']['password']} -e \"CREATE DATABASE #{vagrantConfig['magento']['db_name']};\""
- config.vm.provision "shell", inline: "sudo php /var/www/html/bin/magento setup:install --base-url=\"#{vagrantConfig['magento']['base_url']}\" --db-host=\"#{vagrantConfig['mysql']['host']}\" --db-user=\"#{vagrantConfig['mysql']['username']}\" --db-password=\"#{vagrantConfig['mysql']['password']}\" --db-name=\"#{vagrantConfig['magento']['db_name']}\" --admin-firstname=\"#{vagrantConfig['magento']['admin_firstname']}\" --admin-lastname=\"#{vagrantConfig['magento']['admin_lastname']}\" --admin-email=\"#{vagrantConfig['magento']['admin_email']}\" --admin-user=\"#{vagrantConfig['magento']['admin_user']}\" --admin-password=\"#{vagrantConfig['magento']['admin_password']}\" --backend-frontname=\"#{vagrantConfig['magento']['backend_frontname']}\" --language=\"#{vagrantConfig['magento']['language']}\" --currency=\"#{vagrantConfig['magento']['currency']}\" --timezone=\"#{vagrantConfig['magento']['timezone']}\""
- config.vm.provision "shell", inline: "sudo php /var/www/html/bin/magento deploy:mode:set developer"
- config.vm.provision "shell", inline: "sudo php /var/www/html/bin/magento cache:disable"
- config.vm.provision "shell", inline: "sudo php /var/www/html/bin/magento cache:flush"
- config.vm.provision "shell", inline: "sudo php /var/www/html/bin/magento setup:performance:generate-fixtures /var/www/html/setup/performance-toolkit/profiles/ce/small.xml"
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement