by at15
Where your code runs
You have full physical control, the computer you use in your daily life.
You write code and run everything on your own laptop.
Customers use your application, your code runs on remote server.
A unified develop environment
Create and configure lightweight, reproducible, and portable develop environment.
offical siteVagrant = virtual machine + config tools
Virtual Machine
Virtual Machine
The Xen Project is the leading open source virtualization platform that is powering some of the largest clouds in production today. Amazon Web Services, Aliyun, Rackspace Public Cloud, Verizon Cloud and many hosting services use Xen Project software. Plus, it is integrated into multiple cloud orchestration projects like OpenStack.
Problems for using Virtual Machine
Vagrant Essentials
Vagrantfile
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure(2) do |config| # the base box is ubuntu 14.04 LTS config.vm.box = "ubuntu/trusty64" # need to check update config.vm.box_check_update = true # forward guest 80 to host 8080 config.vm.network "forwarded_port", guest: 80, host: 8080 # Use 777 for the default mount folder. which works for Ubuntu and Mac, windows always got 777 config.vm.synced_folder ".", "/vagrant", \ :disabled => false, \ :mount_options => ['dmode=777,fmode=777'] config.vm.provider "virtualbox" do |vb| # Don't show the GUI unless you have some bug vb.gui = false # Customize the amount of memory on the VM: vb.memory = "1024" # Config the name vb.name = "at15-lnmp" end end
Vagrant base box (image)
vagrant init ubuntu/trusty64
Vagrant share folder
mount Vagrantfile folder to /vagrant by default
bi-direction
Vagrant port mapping
use Vagrant file
# forward guest 80 to host 8080 config.vm.network "forwarded_port", guest: 80, host: 8080
Vagrant commands
Vagrant commands
FAQ
Organize your code
Bad example
Problems
Solutions
The one fits you is the best for you
What happens when you type google.com in your browser and press enter?
The original video is on vimeo. It has omit a lot important procedures due to time limit.
Make HTTP request to the server
Serve static file, route, proxy the request to Application server
Handle business logic, like user login.
The famous web development stack
Free, Easy to learn and use
The best programming language in the world /w\
Easy to use, easy to learn
Hello world
<?php echo 'I am ' . $argv[0] . PHP_EOL; if ( $argc > 1 ) { echo 'Hello ' . $argv[1]; }else{ echo 'Hello /w\\'; } echo PHP_EOL;
Hello world
http://vagrant.lk:8080/index.php<?php $name = '/w\\'; if(isset($_GET['name'])){ $name = $_GET['name']; } echo "Hello {$name}";
I am kidding ...
see the website for full list
Have questions?
tl;dw