Objective
Everyone to VMware or VirtualBox must not be unfamiliar, the benefits of virtualization naturally rooted in, and now we can build a set of similar Laravel homestead Complete development environment through vagrant, which greatly reduces the time to set up the development environment, It also supports the sharing of custom packages on different windows/mac/linux platforms, and the integration of the development environment between teams to improve productivity, and the advent of Docker is also worth looking forward to in the future.
Create a fantastic cross-platform development environment for yourself with vagrant
Update history
July 18, 2015-First draft
Read the original-http://wsgzao.github.io/post/vagrant/
Extended Reading
vagrant-https://www.vagrantup.com/
Laravel Homestead-http://laravel.com/docs/5.1/homestead
Linux Development under Windows: Leveraging vagrant+virtualbox-http://blog.star7th.com/2015/06/1538.html
Build your local development environment with Vagrant under Mac/win7-http://segmentfault.com/a/1190000002645737
Environment preparation
- Git (not required)
- PHP (not required)
- Laravel (not required)
- Composer (not required)
- Vagrant
- VirtualBox
If you have a need to install offline welcome Direct message Reply ha
Install Git
1. Download GitHub for Windows
https://windows.github.com/
Install PHP
We recommend that you try to install the latest version of PHP
1. Download PHP
http://windows.php.net/download/
2. Unzip the Directory
My path to D:\php
3. Add Environment variables
System variables--environment variables---Advanced system settings, right-click Computer-->path
C:\programdata\oracle\java\javapath;%systemroot%\system32;%systemroot%;%systemroot%\system32\wbem;%systemroot %\system32\windowspowershell\v1.0\; C:\nodejs\;D: \php; C:\ProgramData\ComposerSetup\bin
4. Set PHP.ini
Enter the PHP installation directory (for example, D:\php). Locate the Php.ini-development file and copy it to the current directory, rename it to PHP.ini, and modify the following configuration
Remove the semicolon in front of the Extension=php_mbstring.dll (888 rows or so)
Remove the semicolon in front of the Extension=php_openssl.dll (893 rows or so)
Remove Extension_dir = "ext" in front of the semicolon (736 rows or so)
5. Make Environment variables effective
Restart Explorer.exe
Installing Laravel
1. Download Laravel
http://www.golaravel.com/download/
2. Unzip the Directory
My path to D:\laravel-v5.1.4
3. Start Laravel
D:CD laravel-v5.1.4d:\laravel-v5.1.4>php Artisan servelaravel Development Server started on Http://localhost:8000/
Accessing Http://localhost:8000/in the browser
The artisan serve command also supports two parameters:
Host Address Set
Port sets the port number that Web server listens on
Example: PHP artisan serve--port=8888
Installing composer
1. Download Composer-setup.exe
Https://getcomposer.org/doc/00-intro.md#installation-windows
2. Configure composer
Loading composer repositories with package informationinstalling dependencies (including Require-dev) SSL certificate Problem, verify the CA cert is OK. Details:error:14090086:ssl routines:SSL3_GET_SERVER_CERTIFICATE:certificate Verify Failed "
Download Cacert.pem to a custom path if the installation process prompts an error as missing CA certificate
Http://curl.haxx.se/docs/caextract.html
Then modify the php.ini file (1983 rows or so)
Openssl.cafile=d:\php\verify\cacert.pem
3. Test composer
Composer-vcomposer version 1.0-dev (d79427f1a7b15e8f4d46ce8124a4d0c58ba1479c) 2015-07-04 11:22:58
Installing vagrant
1. Download vagrant
Https://www.vagrantup.com/downloads.html
2. Download virtual images offline
Https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.0.0/centos-6.6-x86_64.box
The above gives the centos-6.6 image download link, to download other images please visit the official website
http://www.vagrantbox.es/
Installing VirtualBox
BIOS Open CPU Hardware virtualization support VT (Virtualization Technology)
1. Download VirtualBox
Https://www.virtualbox.org/wiki/Downloads
2. Import the image
Set the VirtualBox directory and copy the image Centos-6.6-x86_64.box
E:\VirtualBox\centos-6.6-x86_64.box
3. Command initialization vagrant
#切换VirtualBox目录e: CD. \virtualbox# input command initialization e:\virtualbox> vagrant init centos6.6a ' vagrantfile ' have been placed in this D Irectory. You're nowready to ' vagrant up ' your first virtual environment! Readthe comments in the vagrantfile as well as documentation on ' vagrantup.com ' for more information on using Vagran T. #执行添加命令E:\virtualbox> vagrant Box add centos6.6 centos-6.6-x86_64.box==> box:adding box ' centos6.6 ' (v0) for Prov Ider: box:downloading:file://e:/virtualbox/centos-6.6-x86_64.box box:progress:100% (rate:670m/s, Estimated time remaining:--:--:--) ==> box:successfully added box ' centos6.6 ' (v0) for ' VirtualBox '! #检查是否导入成功E: \virtu albox> vagrant Box listcentos6.6 (VirtualBox, 0)
Vagrant Configuration
Detailed configuration documentation can be found in the official manual-https://docs.vagrantup.com/v2/
Start vagrant
Execute commands after entering directory E:\VirtualBox through the shell
Vagrant up
The complete process for a smooth start is shown below
E:\virtualbox>vagrant upbringing machine ' default ' up with ' VirtualBox ' provider...==> default:importing base box ' centos6.6 ' ...==> default:matching MAC address for NAT networking...==> default:setting the name of the Vm:virtual Box_default_1437213832296_68434==> default:clearing Any previously set forwarded ports...==> default:clearing Any previously set network interfaces...==> default:preparing network interfaces based on configuration ... default: Adapter 1:nat==> default:forwarding ports ... default:22 = 2222 (Adapter 1) ==> default:booting Vm...==> ; default:waiting to boot. This could take a few minutes ... default:ssh address:127.0.0.1:2222 default:ssh username:vagrant default:ssh A Uth method:private key default:Warning:Connection timeout. Retrying default:default:Vagrant insecure key detected. Vagrant would automatically replace Default:this with a newly generated keypair for better SecuriTy. Default:default:Inserting generated public key within guest ... default:removing insecure key from the guest if it ' s present ... default:key inserted! Disconnecting and reconnecting using new SSH key ... ==> Default:machine booted and ready! ==> default:checking for guest additions in VM ... default:the guest additions on this VM does not match the installed V Ersion of default:virtualbox! In the most cases-fine, but in rare cases it can default:prevent things such as GKFX 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 has installed on Default:your host and reload your VM. Default:default:Guest Additions version:4.3.28 default:virtualbox version:5.0 ==> default:mounting Shared Folders ... default:/vagrant = E:/virtualbox
After the virtual machine starts, it can be vagrant ssh to the virtual machine for further environmental configuration, or software installation related work, under the Windows system, and not directly through the vagrant SSH connection to the virtual machine, need to use securecrt/putty/ Xshell and other third-party tools to connect. Connection address 127.0.0.1, Port 2222. Login account root password is vagrant
e:\virtualbox> vagrant upbringing Machine ' default ' up with ' VirtualBox ' provider...==> default:clearing any Previo usly Set forwarded ports...==> default:clearing any previously set network interfaces...==> default:preparing NETW Ork interfaces based on configuration ... default:adapter 1:nat default:adapter 2:bridged==> Default:forwardi ng ports ... default:80 = 8080 (adapter 1) default:22 = 2222 (adapter 1) ==> default:booting vm...==> default:waiting to boot. This could take a few minutes ... The guest machine entered a invalid state and waiting for ITTO boot. Valid states is ' starting, running '. The machine was in the ' Poweroff ' state. Verify everything is configuredproperly and try again. If the provider you ' re using have a GUI that comes with it, it's often helpful to open that and watch the machine, since T He GUI often have more helpful error messages than Vagrant can retrieve. For example, if you ' re using VirtualBox, run ' vagrant up ' while Thevirtualbox GUI is open.
If you have reported the above error and run VirtualBox to install the system error: Failed to open a session for the virtual machine,unable to load R3 module C:\Program Files \oracle\virtualbox/vboxdd.dll (VBOXDD): getlasterror=1790 (Verr_unresolved_error)., Need to use Universalthemepatcher to restore Themeservice.dll themeui.dll uxtheme.dll files that are not cracked
Already packaged download link-http://pan.baidu.com/s/1c0HGj2g
==> default:booting vm...==> default:waiting to boot. This could take a few minutes ... Default:ssh address:127.0.0.1:2222 default:ssh username:vagrant default:ssh auth method:private key def Ault:Warning:Connection timeout. retrying ... Default:Warning:Connection timeout. retrying ... Default:Warning:Connection timeout. Retrying ...
If the newspaper default:Warning:Connection timeout. Retrying, recommended to hit edit Vagrantfile open VirtualBox graphical interface Vb.gui = True to further parse the error code and cause.
Export box
Execute commands after entering directory E:\VirtualBox through the shell
Vagrant packagevagrant Package--output name--vagrantfile file# optional parameter:--output name: (optional) Set name to specify the output filename--vagrantfile FILE: (optional) vagrantfile can be sealed directly into box
Package.box will be generated in the current directory when it is complete, and can be shared at home or team members for consistent development environments
Other commands
Vagrant Up (Start virtual machine)
Vagrant Halt (shut down the virtual machine?? The corresponding is to shut down the machine)
Vagrant Suspend (pause virtual machine?? Just pause, information such as virtual machine memory will be saved locally as a state file and can be resumed after a recovery operation.
Vagrant Resume (Restore virtual machine?? Corresponds to the previous pause)
Vagrant Box Remove centos6.6 (remove box, where centos6.6 is the box name)
vagrant destroy (Deleting a virtual machine, deleting the configuration in the current virtual machine that is done except for Vagrantfile is not retained)
Laravel Homestead
Details can be found in the official documentation-Http://laravel.com/docs/5.1/homestead
1. Download the installation package
Vagrant Box Add laravel/homesteade:\homestead>vagrant box add laravel/homestead==> box:loading metadata for box ' LA Ravel/homestead ' box:url:https://atlas.hashicorp.com/laravel/homesteadthis box can work with multiple providers! The providers that Itcan work with is listed below. Please review the list and choosethe provider (you'll be working with.1) virtualbox2) Vmware_desktopenter your choice:1= = = box:adding Box ' laravel/homestead ' (v0.2.7) for Provider:virtualbox box:downloading:https:// Vagrantcloud.com/laravel/boxes/homestead/versions/0.2.7/providers/virtualbox.box box:progress:0% (rate:9d/s , Estimated time remaining:0:05:30) 11))
Manual import after offline download due to domestic network environment issues
#输入命令初始化E: \homestead>vagrant init laravela ' vagrantfile ' have been placed in this directory. You're nowready to ' vagrant up ' your first virtual environment! Readthe comments in the vagrantfile as well as documentation on ' vagrantup.com ' for more information on using Vagran T. #执行添加命令E: \homestead>vagrant box Add laravel laravel.box==> Box:box file is not detected as metadata. Adding It directly...==> box:adding box ' laravel ' (v0) for provider:box:Unpacking necessary files from:file://e: /homestead/laravel.box box:progress:100% (rate:141m/s, Estimated time remaining:--:--:--) ==> box:successfully A dded box ' Laravel ' (v0) for ' VirtualBox '! #检查是否导入成功E: \homestead>vagrant box listcentos6.6 (VirtualBox, 0) laravel (virt Ualbox, 0) #启动Lavarel homesteade:\homestead>vagrant upbringing machine ' default ' up with ' VirtualBox ' provider...== > default:importing Base box ' laravel ' ...==> default:matching MAC address for NAT networking...==> Default:set Ting the name of the vm:homestead_default_1437217549272_56101==> default:clearing any previously set network interfaces ...==> default:preparing Network interfaces based on configuration ... default:adapter 1:nat==> Default:forwar Ding ports ... default:22 = 2222 (adapter 1) ==> default:booting vm...==> default:waiting for machine to boo T. This could take a few minutes ... default:ssh address:127.0.0.1:2222 default:ssh username:vagrant default:ss H Auth method:private key default:Warning:Connection timeout. Retrying default:default:Vagrant insecure key detected. Vagrant would automatically replace Default:this with a newly generated keypair for better security. Default:default:Inserting generated public key within guest ... default:removing insecure key from the guest if it ' s present ... default:key inserted! Disconnecting and reconnecting using new SSH key ... ==> Default:machine booted and ready! ==> Default:cHecking for guest additions in VM ... default:the guest additions on this VM does not match the installed version of the default : virtualbox! In the most cases-fine, but in rare cases it can default:prevent things such as GKFX 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 has installed on Default:your host and reload your VM. Default:default:Guest Additions version:4.3.14 default:virtualbox version:5.0 ==> default:mounting Shared Folders ... default:/vagrant = E:/homestead
Sign in to your account vagrant/vagrant and start your new Laravel homestead experience.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.