Use vagrant on Windows to build Laravel homestead for a collaborative cross-platform development environment

Source: Internet
Author: User
Tags ssl certificate virtual environment

Objective

Everyone is VMware VirtualBox not unfamiliar with, and the benefits of virtualization are naturally rooted, and now we can Vagrant build a similar Laravel Homestead complete development environment, which greatly reduces the time to set up the development environment, while also supporting the Windows/Mac/Linux sharing of custom packages on different platforms, The development environment between the Unified team improves productivity, and Docker the emergence of the future is more worthy of expectation.

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
    1. Git (not required)
    2. PHP (not required)
    3. Laravel (not required)
    4. Composer (not required)
    5. Vagrant
    6. 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 pathD:\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 , modify the following configuration
Remove extension=php_mbstring.dll The preceding semicolon (888 rows or so)
Remove extension=php_openssl.dll the preceding semicolon (893 rows or so)
Remove extension_dir = "ext" the preceding semicolon (736 rows or so)

5. Make Environment variables effective

Restartexplorer.exe

Installing Laravel

1. Download Laravel

http://www.golaravel.com/download/

2. Unzip the Directory

My pathD:\laravel-v5.1.4

3. Start Laravel

d:cd laravel-v5.1.4D:\laravel-v5.1.4>on http://localhost:8000/

Accessing Http://localhost:8000/in the browser

artisanThe serve command also supports two parameters:

hostSet the host address
portSet the port number that Web server listens on
For example:php artisan serve --port=8888

Installing composer

1. DownloadComposer-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 that 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

1.02015-07-0411: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#输入命令初始化e:\virtualbox> vagrant Init centos6.6A ' Vagrantfile ' has been placedinchThis directory. You're nowready to ' vagrant up ' your first virtual environment! PleaseReadThe commentsinchThe vagrantfile as well as documentation on ' vagrantup.com ' forMore information on using Vagrant.#执行添加命令e:\virtualbox> vagrant Box Add CENTOS6.6centos-6.6-x86_64.box==> box:adding Box' centos6.6 '(V0) forprovider:box:downloading:file://e:/virtualbox/centos-6.6-x86_64.box box:progress: -% (Rate:670M/s, estimated time remaining:--:--:--) ==> box:successfully added box' centos6.6 '(V0) for ' VirtualBox '!#检查是否导入成功e:\virtualbox> 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 command after entering directory through Shell E:\VirtualBox

 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 forNAT networking...==> default:setting The name of the vm:virtualbox_default_1437213832296_68434==> Default:cleari Ng any previouslySetForwarded ports...==> default:clearing any previouslySetNetwork interfaces...==> default:preparing Network interfaces based on configuration ... default:adapter1: nat==> default:forwarding Ports ... default: A=2222(Adapter1) ==> default:booting vm...==> default:waiting forMachine to boot. This could take a few minutes ... default:ssh address:127.0.0.1:2222Default:ssh username:vagrant default:ssh auth method:private key default:Warning:Connection timeout. Retrying default:default:Vagrant insecure key detected. Vagrant'll automatically replace Default:this with a newly generated keypair forBetter security. Default:default:Inserting generated public key within guest ... default:removing insecure key from the guestifIt ' s present ... default:key inserted! Disconnecting and reconnecting using new SSH key...==> Default:machine booted and ready!==> default:checking for G Uest Additions in VM ... default:the guest additions on this VM does not match the installed version of Default:virtu albox! In the most cases this is fine, but in rare cases it can default:prevent things such as GKFX folders from working proper Ly. If you see default:shared folder errors, please make sure the guest additions within the default:virtual machine m    Atch 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 fo Lders. 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 vagrant ssh connected to the virtual machine, you need to use SecureCRT/Putty/Xshell such third-party tools to connect. Connection address 127.0.0.1 , Port 2222 . The password for the login account is rootvagrant

E:\virtualbox> vagrant upbringing Machine' Default 'Up with' VirtualBox 'Provider...==> default:clearing any previouslySetForwarded ports...==> default:clearing any previouslySetNetwork interfaces...==> default:preparing Network interfaces based on configuration ... default:adapter1: Nat Default:adapter2: bridged==> default:forwarding Ports ... default: the=8080(Adapter1) Default: A=2222(Adapter1) ==> default:booting vm...==> default:waiting forMachine to boot. This could take a few minutes ... The guest machine entered a invalid state whileWaiting forITTO boot. Valid states is' starting, running '. The machine isinchThe' Poweroff 'State. Verify everything is configuredproperly and try again. If the provider you' re using have a GUI that comes with it,it are often helpful to open that and watch the machine, since Thegui often have More helpful error messages than Vagrant can retrieve. For example, if you 'Re using VirtualBox, run ' vagrant up ' whileThevirtualbox GUI is open.

If there is a report of 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). , you need to use to UniversalThemePatcher restore the non-cracked themeservice.dll themeui.dll uxtheme.dll files

Already packaged download link-http://pan.baidu.com/s/1c0HGj2g

for machine to boot. This may take a few minutes...    127.0.0.1:2222    default: SSH username: vagrant    default: SSH auth method: private key    default: Warning: Connection timeout. Retrying...    default: Warning: Connection timeout. Retrying...    default: Warning: Connection timeout. Retrying...

If default: Warning: Connection timeout. Retrying... the newspaper, suggest to hit edit Vagrantfile open VirtualBox graphical interface vb.gui = true further analysis error code and reason.

Export box

Execute command after entering directory through Shell E:\VirtualBox

vagrant packagevagrant package --output NAME --vagrantfile FILE#可选参数:--output NAME : (可选)设置通过NAME来指定输出的文件名--vagrantfile FILE:(可选)可以将Vagrantfile直接封进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 (Turn off the virtual machine-the corresponding is the shutdown)
Vagrant Suspend (Pause virtual machine-just pause, virtual machine memory and other information will be saved locally as a state file and can continue to be used after a recovery operation)
Vagrant Resume (restores the 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 forBox' Laravel/homestead 'Box:url:https://atlas.hashicorp.com/laravel/homesteadthis box can work with multiple providers! The providers that Itcan work with is listed below. Review the list and choosethe provider you'll be a working with.1) VirtualBox2) Vmware_desktopenter Your choice:1==> box:adding Box' Laravel/homestead '(V0.2.7) forProvider: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: to: -) One))

Manual import after offline download due to domestic network environment issues

#输入命令初始化E:\homestead>vagrant init laravela ' vagrantfile ' has been placedinchThis directory. You're nowready to ' vagrant up ' your first virtual environment! PleaseReadThe commentsinchThe vagrantfile as well as documentation on ' vagrantup.com ' forMore information on using Vagrant.#执行添加命令E:\homestead>vagrant box Add laravel laravel.box==> Box:box file is not detected as metadata. Adding It directly...==> box:adding box' Laravel '(V0) forprovider:box:Unpacking necessary Files From:file://e:/homestead/laravel.box box:progress: -% (Rate:141M/s, estimated time remaining:--:--:--) ==> box:successfully added box' Laravel '(V0) for ' VirtualBox '!#检查是否导入成功E:\homestead>vagrant Box LISTCENTOS6.6(VirtualBox,0) Laravel (VirtualBox,0)#启动Lavarel HomesteadE:\homestead>vagrant upbringing Machine' Default 'Up with' VirtualBox 'provider...==> default:importing Base Box' Laravel '...==> default:matching MAC Address forNAT networking...==> default:setting The name of the vm:homestead_default_1437217549272_56101==> Default:clearin G any previouslySetNetwork interfaces...==> default:preparing Network interfaces based on configuration ... default:adapter1: nat==> default:forwarding Ports ... default: A=2222(Adapter1) ==> default:booting vm...==> default:waiting forMachine to boot. This could take a few minutes ... default:ssh address:127.0.0.1:2222Default:ssh username:vagrant default:ssh auth method:private key default:Warning:Connection timeout. Retrying default:default:Vagrant insecure key detected. Vagrant'll automatically replace Default:this with a newly generated keypair forBetter security. Default:default:Inserting generated public key within guest ... default:removing insecure key from the guestifIt' s present ... default:key inserted! Disconnecting and reconnecting using new SSH key...==> Default:machine booted and ready!==> default:checking for G Uest Additions in VM ... default:the guest additions on this VM does not match the installed version of Default:virtu albox! In the most cases this is fine, but in rare cases it can default:prevent things such as GKFX folders from working proper Ly. If you see default:shared folder errors, please make sure the guest additions within the default:virtual machine m    Atch 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 fo Lders. Default:/vagrant = E:/homestead

Sign in vagrant/vagrant to your account and start your new Laravel Homestead experience.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Use vagrant on Windows to build Laravel homestead for a collaborative cross-platform development environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.