Accessing apache on a vagrant sandbox using ssl (port forwarding)

前端 未结 2 713
太阳男子
太阳男子 2021-02-01 23:53

I\'ve built a vagrant/virtualbox web server as a development sandbox, and configured apache in the VM for ssl (on the default port 443, with a self-signed certificate). I\'ve te

2条回答
  •  无人及你
    2021-02-02 00:18

    The answer above would require you to keep repeating steps 2 and 3 each time you destroy the box. I'd suggest you use Chef to achieve your goal. See the example below:

    # -*- mode: ruby -*-
    # vi: set ft=ruby :
    
    Vagrant.configure(2) do |config|
    
        config.vm.box       = "precise64"
        config.vm.box_url   = "http://files.vagrantup.com/precise64.box"
    
        config.vm.network :forwarded_port, guest: 80, host: 8080
        config.vm.network :forwarded_port, guest: 443, host: 443
    
        config.vm.network "private_network", ip: "192.168.33.10"
    
        config.vm.provision :chef_solo do |chef|
    
            chef.cookbooks_path = "/path/to/your/cookbooks"
    
            # Install PHP
            chef.add_recipe "php"
            chef.add_recipe "php::module_mysql"
    
            # Setup Apache
            chef.add_recipe "apache2"
            chef.add_recipe "apache2::mod_php5"
    
            chef.json = { :apache => { :default_site_enabled => true } }
    
        end
    
    end
    

提交回复
热议问题