Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"vagrant up" ok but can't access via browser

I'm trying Vagrant for first time on OSX Yosemite and downloaded Vagrantfile/Cheffile from http://rove.io with LAMP stack.

Here they are:

cheffile

# encoding: utf-8

site 'http://community.opscode.com/api/v1'

cookbook "apt"
cookbook "mysql", {}
cookbook "nodejs", {:github=>"mdxp/nodejs-cookbook"}
cookbook "python", {}
cookbook "git", {}
cookbook "php", {}
cookbook "nginx", {}

vagrantfile

# encoding: utf-8
# This file originally created at http://rove.io/36f03d7ed905b30118b48bfe3d16ee07

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

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

  config.vm.box = "opscode-ubuntu-12.04_chef-11.4.0"
  config.vm.box_url = "https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_chef-11.4.0.box"
  config.ssh.forward_agent = true

  config.vm.network :forwarded_port, guest: 80, host: 8080

  config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = ["cookbooks"]
    chef.add_recipe :apt
    chef.add_recipe 'mysql::server'
    chef.add_recipe 'nodejs'
    chef.add_recipe 'python'
    chef.add_recipe 'git'
    chef.add_recipe 'php'
    chef.add_recipe 'nginx'
    chef.json = {
      :mysql => {
        :server_root_password   => "password",
        :server_repl_password   => "password",
        :server_debian_password => "password",
        :service_name           => "mysql",
        :basedir                => "/usr",
        :data_dir               => "/var/lib/mysql",
        :root_group             => "root",
        :mysqladmin_bin         => "/usr/bin/mysqladmin",
        :mysql_bin              => "/usr/bin/mysql",
        :conf_dir               => "/etc/mysql",
        :confd_dir              => "/etc/mysql/conf.d",
        :socket                 => "/var/run/mysqld/mysqld.sock",
        :pid_file               => "/var/run/mysqld/mysqld.pid",
        :grants_path            => "/etc/mysql/grants.sql"
      },
      :git   => {
        :prefix => "/usr/local"
      },
      :nginx => {
        :dir                => "/etc/nginx",
        :log_dir            => "/var/log/nginx",
        :binary             => "/usr/sbin/nginx",
        :user               => "www-data",
        :init_style         => "runit",
        :pid                => "/var/run/nginx.pid",
        :worker_connections => "1024"
      }
    }
  end
end

So, then I tried get this up:

$ librarian-chef install
$ vagrant up

➜  myapp git:(master) ✗ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: VirtualBox VM is already running.
➜  myapp git:(master) ✗ vagrant reload
==> default: Attempting graceful shutdown of VM...
==> default: Clearing any previously set forwarded ports...
Skipping Berkshelf with --no-provision
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 => 2200 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2200
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 4.2.12
    default: VirtualBox Version: 4.3
==> default: Mounting shared folders...
    default: /vagrant => /Users/myuser/projects/dev
    default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks => /Users/myuser/projects/dev/cookbooks
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: to force provisioning. Provisioners marked to run always will still run.

I guess it's working, right?

I'm trying http://127.0.0.1 on Chrome and it says not found.

Am I doing something wrong?

like image 315
anderlaini Avatar asked Oct 21 '25 22:10

anderlaini


1 Answers

You need to access via the ip of vm box using following steps.

ssh to vagrant box

vagrant ssh

$ ifconfig

copy the id and open in browser. IP should be something like 192.168.1.5 and in browser, open http://192.168.1.5:8080

like image 54
Neeraj Kumar Avatar answered Oct 25 '25 17:10

Neeraj Kumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!