Question

I created a debian vm and via puphet I just created one virtual host and pointed the local ip it created inside my hosts host file. But now when I try creating another it wont work. I've read other threads such as:

creating virtual hosts on a vagrant box which mentions to use chef. But what i don't understand is why wont it work the normal way? By the normal way i mean creating a new vhost file in /etc/apache2/sites-available , enabling it and just creating the path with ip in my local machines host file. What is chef doing that I cant do manually?

Here is my vagrant file:

Vagrant.configure("2") do |config|
  config.vm.box = "debian-wheezy72-x64-vbox43"
  config.vm.box_url = "https://puphpet.s3.amazonaws.com/debian-wheezy72-x64-vbox43.box"

  config.vm.network "private_network", ip: "192.168.56.101"

  config.vm.synced_folder "/Volumes/www", "/var/www", id: "vagrant-root", :nfs => false

  config.vm.usable_port_range = (2200..2250)
  config.vm.provider :virtualbox do |virtualbox|
    virtualbox.customize ["modifyvm", :id, "--name", "wheezyDEB"]
    virtualbox.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    virtualbox.customize ["modifyvm", :id, "--memory", "512"]
    virtualbox.customize ["setextradata", :id, "--VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
  end

  config.vm.provision :shell, :path => "shell/initial-setup.sh"
  config.vm.provision :shell, :path => "shell/update-puppet.sh"
  config.vm.provision :shell, :path => "shell/librarian-puppet-vagrant.sh"
  config.vm.provision :puppet do |puppet|
    puppet.facter = {
      "ssh_username" => "vagrant"
    }

    puppet.manifests_path = "puppet/manifests"
    puppet.options = ["--verbose", "--hiera_config /vagrant/hiera.yaml", "--parser future"]
  end

  config.ssh.username = "vagrant"

  config.ssh.shell = "bash -l"

  config.ssh.keep_alive = true
  config.ssh.forward_agent = false
  config.ssh.forward_x11 = false
  config.vagrant.host = :detect
end
Was it helpful?

Solution

I figured it out, i'm not sure if this is the correct way of doing it but it works and thats all that matters. If anyone has a better or faster way let me know.

This is what i did:

1) I had origionally used puphet from puphet.com
2) i had origionally used puphet from puphet.com
3) i went into the directory where puhpet gave me so i went into mypath/puppet/hieradata and opened common.yaml
4) under vhosts: are the vhost settings, example: <

vhosts:
        VO6aT11EHJmL:
            servername: localhost
            docroot: /var/www/public
            port: '80'
            setenv:
                - 'APP_ENV dev'
            override:
                - All
        4yNJr1LpLJYA:
            servername: laravel.dev
            docroot: /var/www/vhosts/laravel-dev
            port: '80'
            setenv:
                - 'APP_ENV dev'
            override:
                - all

Each vhost is given a unique identification name and it can be anything. The options for servername, docroot seem simple so modify these.

Next, in order for the virtual machine to reconize your updates make sure your vagrant is stopped while making these changes into common.yaml and after your done and save type vagrant up into terminal. Once its up go into your directories where your sites-available directory is. In my case i'm using apache under debian; Same goes for ubuntu.

/etc/apache2/sites-available

the files that you see here, their name matches the unique names that you have in the common.yaml file except there are numbers in them for example:

#-unique_name.conf

so in the common.yaml file if you created or modified settings under 4yNJr1LpLJYA you would need to look for #-4yNJr1LpLJYA.conf in this directory and match the settings as you have in your common.yaml file. Once you are done restart your server, in my case its

sudo service apache reload

also dont forget to add the virtual host into your local machines host file and match it with the same ip that puphet gave you. for example:

192.168.56.101 my-virtual-domain

do this for each one that you want to add.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top