vagrantvagrantfilevagrant-windows

Access website from browser in vagrant


On windows 10 I have ran my vagrant up and then ssh into my vm successfully. Installed apache2 php5-cli php5 libapache2-mod-php

Now when i access localhost:8080 it is showing me apache default welcome page. How can i access my site in the browser ?

Here are the contents of my Vagrantfile

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

Vagrant.configure(2) do |config|
  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://atlas.hashicorp.com/search.
  config.vm.box = "ubuntu/trusty64"

  # 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.
  config.vm.network "forwarded_port", guest: 80, host: 8080
end

This is my current directory structure enter image description here


Solution

  • You'll need to get your data into the VM and configure Apache to serve that data. For starters, add this to you Vagrantfile (after the confiv.vm.network line):

    config.vm.synced_folder ".", "/var/www/html"
    

    It will make your app folder available under /var/www/html on the VM. Apache on Ubuntu serves from that folder by default, so you should be able to see something after doing vagrant reload.