R
R
Rostislav2018-01-25 15:51:38
virtual box
Rostislav, 2018-01-25 15:51:38

How to set up vagrant + virtualbox on windows 10 for many sites (as it is done on hosting)?

I'm trying to set up vagrant to make development easier.
The idea is to do about the same as on hosting.
Create 1 project in PhpStorm (eg dev_server), configure the server itself. Store all sites in the public_html folder. Install everything you need globally (gulp, npm, different clis, etc.) so you don't have to download the same packages for every project. In PhpStorm, create a separate project for each site (to work with a specific project, deployment settings, etc.)
I tried to do it with ubuntu/trusty64, but something did not work. I can't figure out how to access the site from a browser.
Did something like this:

vagrant init ubuntu/trusty64
vagrant up

Then I installed apache2 and everything else (php, phpmyadmin, git, etc.).
In /etc/apache2/sites-available/000-default.conf I wrote
<VirtualHost *:80>
  DocumentRoot "/var/www/public_html/site1.loc"
  ServerName site1.loc
  <Directory "/var/www/public_html/site1.loc">
    AllowOverride All
  </Directory>
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot "/var/www/public_html/site2.loc"
  ServerName site2.loc
  <Directory "/var/www/public_html/site2.loc">
    AllowOverride All
  </Directory>
</VirtualHost>

Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.hostname = "test.dev.loc"
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
config.ssh.insert_key = false

# Optional NFS. Make sure to remove other synced_folder line too
config.vm.synced_folder ".", "/var/www", :nfs => { :mount_options => ["dmode=777","fmode=777",'actimeo=1'] }
# config.vm.provision :shell, path: "shell.sh"
end

Tell me step by step in a nutshell what and why to configure, and there I will already google.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nfire, 2018-01-25
@nfire

First, make sure that the necessary ports are forwarded to the virtual machine and that the necessary ports are working.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question