1

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

tarleb
  • 19,863
  • 4
  • 51
  • 80
Raheel
  • 8,716
  • 9
  • 60
  • 102

2 Answers2

2

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.

tarleb
  • 19,863
  • 4
  • 51
  • 80
  • Actually app is not my root folder instead api.dukaan.pk is the folder i want to sync but i am in windows – Raheel Nov 25 '15 at 15:52
  • 1
    @RaheelKhan Changed the answer to share the full directory. Should work on windows. If it doesn't try specifying "smb" as the method for sharing: `config.vm.synced_folder ".", "/var/www/html", type: "smb"` or install cygwin and use rsync. – tarleb Nov 25 '15 at 16:28
  • Working Thanks. Do you know how can i make a virtual host for this folder ? I created api.dukaan.pk.conf file in my vm /etc/apache2/sites-available directory. Then i ran sudo a2ensite api.dukaan.pk.conf . Then in my windows host file i added 127.0.0.1 api.dukaan.pk When i access api.dukaan.pk a blank white page occurs – Raheel Nov 25 '15 at 16:40
  • You may have to reload apache so it notices the new config: `sudo systemctl reload apache2`. – tarleb Nov 25 '15 at 16:45
  • i did sudo service apache2 restart – Raheel Nov 25 '15 at 16:51
  • No idea then, sorry. Would possibly warrant a separate question at http://serverfault.com or http://superuser.com – tarleb Nov 25 '15 at 16:54
  • 1
    its working when i used `config.vm.network "private_network", ip: "192.168.33.10"` and in windows host file i used this ip address to map api.dukaan.pk (Not sure if i am going in right direction or not ) – Raheel Nov 25 '15 at 16:58
0

when you edit the configuration file by using vim or any other editor. After that, you have to reload the vagrant and then try to access the localhost:8080

Use the command

vagrant reload

enter image description here

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
  • Please copy and paste the console output instead of adding it as a picture. Thanks. – hko Jan 19 '23 at 01:12