Advertisement
RenoAxel

Magento 2 Developer's Guide Ubuntu 18.04 (Updated)

May 23rd, 2019
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.90 KB | None | 0 0
  1. # -*- mode: ruby -*-
  2. # vi: set ft=ruby :
  3.  
  4. require 'yaml'
  5.  
  6. vagrantConfig = YAML.load_file 'Vagrantfile.config.yml'
  7.  
  8. # All Vagrant configuration is done below. The "2" in Vagrant.configure
  9. # configures the configuration version (we support older styles for
  10. # backwards compatibility). Please don't change it unless you know what
  11. # you're doing.
  12. Vagrant.configure("2") do |config|
  13.   # The most common configuration options are documented and commented below.
  14.   # For a complete reference, please see the online documentation at
  15.   # https://docs.vagrantup.com.
  16.  
  17.   # Every Vagrant development environment requires a box. You can search for
  18.   # boxes at https://vagrantcloud.com/search.
  19.   config.vm.box = "ubuntu/bionic64"
  20.  
  21.   # Disable automatic box update checking. If you disable this, then
  22.   # boxes will only be checked for updates when the user runs
  23.   # `vagrant box outdated`. This is not recommended.
  24.   # config.vm.box_check_update = false
  25.  
  26.   # Create a forwarded port mapping which allows access to a specific port
  27.   # within the machine from a port on the host machine. In the example below,
  28.   # accessing "localhost:8080" will access port 80 on the guest machine.
  29.   # NOTE: This will enable public access to the opened port
  30.   # config.vm.network "forwarded_port", guest: 80, host: 8080
  31.  
  32.   # Create a forwarded port mapping which allows access to a specific port
  33.   # within the machine from a port on the host machine and only allow access
  34.   # via 127.0.0.1 to disable public access
  35.   # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
  36.  
  37.   # Create a private network, which allows host-only access to the machine
  38.   # using a specific IP.
  39.   config.vm.network "private_network", ip: vagrantConfig['ip']
  40.  
  41.   # Create a public network, which generally matched to bridged network.
  42.   # Bridged networks make the machine appear as another physical device on
  43.   # your network.
  44.   # config.vm.network "public_network"
  45.  
  46.   # Share an additional folder to the guest VM. The first argument is
  47.   # the path on the host to the actual folder. The second argument is
  48.   # the path on the guest to mount the folder. And the optional third
  49.   # argument is a set of non-required options.
  50.   # config.vm.synced_folder "../data", "/vagrant_data"
  51.  
  52.   # Mount local "~/www/B05032-Magento-Box/" path into box's "/vagrant-B05032-Magento-Box/" path  
  53.   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"]
  54.  
  55.   # Provider-specific configuration so you can fine-tune various
  56.   # backing providers for Vagrant. These expose provider-specific options.
  57.   # Example for VirtualBox:
  58.   #
  59.   config.vm.provider "virtualbox" do |vb|
  60.     # Display the VirtualBox GUI when booting the machine
  61.     vb.gui = false
  62.  
  63.     # Customize the amount of memory on the VM:
  64.     vb.memory = "2048"
  65.  
  66.     # Customize CPUS
  67.     vb.cpus = 2
  68.   end
  69.  
  70.   # View the documentation for the provider you are using for more
  71.   # information on available options.
  72.  
  73.   # Enable provisioning with a shell script. Additional provisioners such as
  74.   # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  75.   # documentation for more information about their specific syntax and use.
  76.   # config.vm.provision "shell", inline: <<-SHELL
  77.   #   apt-get update
  78.   #   apt-get install -y apache2
  79.   # SHELL
  80.   #config.vm.provision "file", source: "~/.gitconfig", destination:".gitconfig"
  81.   config.vm.provision "shell", inline: "sudo apt-get update"
  82.  
  83.   #Apache
  84.   config.vm.provision "shell", inline: "sudo apt-get -y install apache2"
  85.   config.vm.provision "shell", inline: "sudo update-rc.d apache2 defaults"
  86.   config.vm.provision "shell", inline: "sudo service apache2 start"
  87.   config.vm.provision "shell", inline: "sudo a2enmod rewrite"
  88.   config.vm.provision "shell", inline: "sudo awk '/<Directory\\/>/,/AllowOverride None/{sub(\"None\", \"All\",$0)}{print}' /etc/apache2/apache2.conf > /tmp/tmp.apache2.conf"
  89.   config.vm.provision "shell", inline: "sudo mv /tmp/tmp.apache2.conf /etc/apache2/apache2.conf"
  90.   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"
  91.   config.vm.provision "shell", inline: "sudo mv /tmp/tmp.apache2.conf /etc/apache2/apache2.conf"
  92.   config.vm.provision "shell", inline: "sudo service apache2 stop"
  93.  
  94.   #PHP
  95.   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"
  96.   config.vm.provision "shell", inline: "sudo apt install libapache2-mod-php7.2"
  97.   config.vm.provision "shell", inline: "echo \"xdebug.max_nesting_level=200\">> /etc/php/7.2/apache2/php.ini"
  98.   config.vm.provision "shell", inline: 'sudo sed -i "s/memory_limit = .*/memory_limit = 1024M/" /etc/php/7.2/apache2/php.ini'
  99.   config.vm.provision "shell", inline: 'sudo sed -i "s/upload_max_filesize = .*/upload_max_filesize = 256M/" /etc/php/7.2/apache2/php.ini'
  100.   config.vm.provision "shell", inline: 'sudo sed -i "s/zlib.output_compression = .*/zlib.output_compression = on/" /etc/php/7.2/apache2/php.ini'
  101.   config.vm.provision "shell", inline: 'sudo sed -i "s/max_execution_time = .*/max_execution_time = 18000/" /etc/php/7.2/apache2/php.ini'
  102.   config.vm.provision "shell", inline: 'sudo sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.2/apache2/php.ini'
  103.   config.vm.provision "shell", inline: 'sudo sed -i "s/;opcache.save_comments.*/opcache.save_comments = 1/" /etc/php/7.2/apache2/php.ini'
  104.   config.vm.provision "shell", inline: "sudo apt-get -y install phpunit"
  105.  
  106.   #MySQL
  107.   config.vm.provision "shell", inline: "sudo debconf-set-selections <<<'mysql-server mysql-server/root_password password #{vagrantConfig['mysql']['password']}'"
  108.   config.vm.provision "shell", inline: "sudo debconf-set-selections <<<'mysql-server mysql-server/root_password_again password #{vagrantConfig['mysql']['password']}'"
  109.   config.vm.provision "shell", inline: "sudo apt-get -y install mysql-server"
  110.   config.vm.provision "shell", inline: "sudo service mysql start"
  111.   config.vm.provision "shell", inline: "sudo update-rc.d mysql defaults"
  112.  
  113.   #Magento
  114.   config.vm.provision "shell", inline: "sudo rm -Rf /var/www/html"
  115.   config.vm.provision "shell", inline: "sudo ln -s #{vagrantConfig['synced_folder']['guest_path']} /var/www/html"
  116.   config.vm.provision "shell", inline: "curl -sS https://getcomposer.org/installer | php", privileged: false
  117.   config.vm.provision "shell", inline: "mv composer.phar /usr/local/bin/composer", privileged: false
  118.   config.vm.provision "shell", inline: "composer clearcache", privileged: false
  119.   config.vm.provision "shell", inline: "composer -V", privileged: false
  120.   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"
  121.   config.vm.provision "shell", inline: "composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition /var/www/html/"
  122.   config.vm.provision "shell", inline: "sudo mysql --user=#{vagrantConfig['mysql']['username']} --password=#{vagrantConfig['mysql']['password']} -e \"CREATE DATABASE #{vagrantConfig['magento']['db_name']};\""
  123.   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']}\""
  124.   config.vm.provision "shell", inline: "sudo php /var/www/html/bin/magento deploy:mode:set developer"
  125.   config.vm.provision "shell", inline: "sudo php /var/www/html/bin/magento cache:disable"
  126.   config.vm.provision "shell", inline: "sudo php /var/www/html/bin/magento cache:flush"
  127.   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"
  128. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement