Setting up Vagrant with PuPHET failure

2019-06-14 06:49发布

问题:

I'm using PuPHET tool to setup Vagrant so that a combo vagrant+puppet should just easily boot a VM with vagrant up. Im using a Centos64 setup - php 5.4, and some minor standard debug mode. Im running this on a Mac OSX Maverick.

Here is the configuration:

vagrantfile-local:
    vm:
        box: centos64-x64-vbox43-1383512148
        box_url: 'http://box.puphpet.com/centos64-x64-vbox43.box'
        hostname: null
        network:
            private_network: 192.168.56.101
            forwarded_port:
                OhyIDGb9LuDg:
                    host: '7943'
                    guest: '22'
        provider:
            virtualbox:
                modifyvm:
                    natdnshostresolver1: on
                    memory: '1024'
                setextradata:
                    VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root: 1
        provision:
            puppet:
                manifests_path: puphpet/puppet
                manifest_file: manifest.pp
                options:
                    - '--verbose'
                    - '--hiera_config /vagrant/puphpet/puppet/hiera.yaml'
                    - '--parser future'
        synced_folder:
            ppWP2lt1BsDi:
                id: vagrant-root
                source: '/Users/Documents/vagrant/www/'
                target: /var/www
                nfs: 'false'
        usable_port_range: 2200..2250
    ssh:
        host: null
        port: null
        private_key_path: null
        username: vagrant
        guest_port: null
        keep_alive: true
        forward_agent: false
        forward_x11: false
        shell: 'bash -l'
    vagrant:
        host: detect
server:
    packages:
        - vim-common
        - git
    dot_files:
        -
            bash_aliases: null
    _prevent_empty: ''
mailcatcher:
    install: 0
    settings:
        smtp_ip: 0.0.0.0
        smtp_port: 1025
        http_ip: 0.0.0.0
        http_port: '1080'
        path: /usr/local/bin
        log: /var/log/mailcatcher/mailcatcher.log
apache:
    modules:
        - php
        - rewrite
    vhosts:
        geXjvySSeKG4:
            servername: test.dev
            docroot: /var/www/public_html
            port: '80'
            setenv:
                - 'APP_ENV dev'
            override:
                - All
    user: www-data
    group: www-data
    default_vhost: true
    mpm_module: prefork
    mod_pagespeed: 0
    mod_spdy: 0
php:
    version: '54'
    composer: '1'
    modules:
        php:
            - cli
            - intl
            - mcrypt
            - cgi
            - memcache
            - pspell
            - tidy
        pear: {  }
        pecl:
            - pecl_http
    ini:
        display_errors: On
        error_reporting: '-1'
        session.save_path: /var/lib/php/session
        allow_url_fopen: '1'
        allow_url_include: '1'
        error_log: syslog
        apc.enabled: '1'
    timezone: America/Chicago
xdebug:
    install: '1'
    settings:
        xdebug.default_enable: '1'
        xdebug.remote_autostart: '0'
        xdebug.remote_connect_back: '1'
        xdebug.remote_enable: '1'
        xdebug.remote_handler: dbgp
        xdebug.remote_port: '9000'
drush:
    install: 0
    settings:
        drush.tag_branch: 6.x
mysql:
    root_password: ***
    phpmyadmin: '1'
    adminer: 0
    databases:
        kqca9cVkAol1:
            grant:
                - ALL
            name: ***
            host: localhost
            user: ***
            password: ***
            sql_file: ''
mongodb:
    install: 0
    auth: 1
    port: '27017'
    databases: {  }
beanstalkd:
    install: '1'
    settings:
        listenaddress: 10.0.1.5
        listenport: '13000'
        maxjobsize: '65535'
        maxconnections: '1024'
        binlogdir: /var/lib/beanstalkd/binlog
        binlogfsync: null
        binlogsize: '10485760'
    beanstalk_console: '1'
    binlogdir: /var/lib/beanstalkd/binlog
rabbitmq:
    install: 0
    port: '5672'

Now I have also modified the host file found in /etc/hosts and added 192.168.56.101 test.dev

I can ping by IP, I can ping by domain name, I can even vagrant ssh into the VM..

Problem? I cant access it on the browser (which defeats the purpose of the setup). I've dumped a simple php hello world script inside the share folder. I have SSH into the VM to see if its there and it is. But im so lost as to why its not working out of the box? I have also tried to access both on 7943 or 22 port. No avail.

回答1:

I managed to get this working. When working with Vagrant I generally choose either private network or port forwarding but never both.

If you change your yaml configuration in the forwarded ports section and add

forwarded_port:
    OhyIDGb9LuDg:
        host: '7943'
        guest: '22'
    GET0RirwFFW:
        host: '8080'
        guest: '80'

You can then access the virtual host at http://awesome.dev:8080. Note the port 8080 on the end, this means that port 8080 on the host machine is being forwarded to port 80 on the guest.

Here is a screenshot of it working. http://cdn.imghack.se/images/e38b9d2debc888588581c46b4aebb2c0.png