项目作者: jojoee

项目描述 :
Vagrant examples
高级语言: HTML
项目地址: git://github.com/jojoee/vagrant-examples.git
创建时间: 2017-03-19T12:48:45Z
项目社区:https://github.com/jojoee/vagrant-examples

开源协议:MIT License

下载


vagrant-examples

  • Vagrant: Manages VM software
  • Vagrantfile: virtual machine configuration

Getting started

  1. Install VirtualBox
  2. Install Vagrant, after install Vagrant, it’ll update our hosts file
  3. Go to directory: cd baked-lamp
  4. Start: vagrant up

CLI

  1. Basic
  2. $ vagrant help
  3. $ vagrant -v
  4. $ vagrant box list
  5. $ vagrant box update
  6. $ vagrant init [box-name]
  7. $ vagrant init ubuntu/trusty64
  8. $ vagrant up
  9. To access
  10. $ vagrant ssh
  11. Plugin
  12. $ vagrant plugin list
  13. # vagrant plugin update
  14. $ vagrant plugin install <plugin-name>
  15. $ vagrant plugin install vagrant-vbguest
  16. While running
  17. $ vagrant provision
  18. $ vagrant suspend...........pause
  19. $ vagrant halt..............power off VM
  20. $ vagrant destroy...........stop and remove VM
  21. $ vagrant status
  22. $ vagrant reload
  23. Box
  24. $ vagrant box add <box-name> [box-path]
  25. $ vagrant box add ubuntu/trusty64
  26. $ vagrant box add laravel/homestead
  27. $ vagrant box add debian/jessie64
  28. $ vagrant box add centos/7
  29. $ vagrant box add miya0001/vccw
  30. $ vagrant remove <box-name>

Provisioning

Baked: make it from scratch

  1. $ vagrant up
  2. $ vagrant ssh
  3. Inside VM
  4. $ sudo yum update -y
  5. $ sudo yum install -y nano git unzip screen
  6. $ sudo yum install -y httpd httpd-devel httpd-tools
  7. $ sudo yum install -y php php-cli php-common php-devel php-mysql
  8. $ sudo chkconfig --add httpd
  9. $ sudo chkconfig httpd on
  10. $ cd /var/www
  11. $ sudo rm -rf html
  12. $ sudo ln -s /vagrant /var/www/html
  13. $ sudo service httpd restart
  14. $ sudo yum install -y mysql mysql-server mysql-devel
  15. $ sudo chkconfig --add mysqld
  16. $ sudo chkconfig mysqld on
  17. $ sudo service mysqld start
  18. $ mysql -u root -e "CREATE DATABASE IF NOT EXISTS jojoee_test";
  19. $ mysql -u root -e "SHOW DATABASES";
  20. $ exit
  21. Export to box
  22. $ vagrant status
  23. $ vagrant package --output baked-lamp.box
  24. $ vagrant box add "jojoee/baked-lamp" baked-lamp.box
  25. Test
  26. $ cd baked-lamp-test
  27. $ vagrant up
  28. http://localhost:8080/
  29. http://localhost:8080/index.php
  30. http://localhost:8081/
  31. http://localhost:8081/index.php

Update

  • Work with database (e.g. MySQL)
  • Plugin

Reference