laravel homestead vagrant box安装使用,问题,及相关命令
Vagrant is a tool that manages oracle virtual boxes
1.本地下载https://atlas.hashicorp.com/laravel/boxes/homestead/versions/0.2.6/providers/virtualbox.box下载该box作为base,
(https://atlas.hashicorp.com/boxes/search?utf8=%E2%9C%93&sort=&provider=&q=homestead可以用来查询有哪些box)
https://atlas.hashicorp.com/antoniofrignani/boxes/laravel-homestead-settler-32/versions/0.1.1/providers/virtualbox.box
2.本地添加 vagrant box add laravel/homestead (path to downloaded file)(base box above!)
3.git clone https://github.com/laravel/homestead.git Homestead
4.运行init.sh将生成Homestead.yaml配置文件(实际上在Homestead目录将创建Vagrantfile,Homestead.yaml只是populate这个vagrantfile的脚本,方便配置(相当于执行vagrant init)
5.配置相关参数
http://laravel.com/docs/5.1/homestead
6.vagrant up即可使用了(直接调用virtualbox的api将基于base box的vagrantfile代表的客制化环境(shared folder,network,memroy,forwarded ports etc)运行起来)
https://phphub.org/topics/2
Homestead 包括以下两个东西
- 一个 vagrant box 虚拟机, 里面软件什么都下载好了;
- Github 代码库, 里面装载着 vagrant 的配置脚本, 用来自动化配置网络, 端口映射, 等一些开发时候用到的配置;
windows下如果出现解压错误,那么可以使用一下方法解决
The executable 'bsdtar' Vagrant is trying to run was not
found in the %PATH% variable. This is an error. Please verify
this software is installed and on the path.
解决方案是从sourceforge.net下载一个bsdtar.exe basic_bsdtar.exe from here http://sourceforge.net/projects/mingw/files/MinGW/Extension/bsdtar/ and rename it to bsdtar.exe and place it in C:\HashiCorp\Vagrant\embedded\gnuwin32\bin\
在win7中,当vagrant up时出现如下错误:
Unable to load R3 module D:\Program Files\Oracle\VirtualBox/VBoxDD.dll (VBoxDD):GetLastError= (VERR_UNRESOLVED_ERROR)
则可能是因为
本目录中的以下三个文件是原始的未被破解的WIN7 64位系统主题文件:
themeservice.dll
themeui.dll
uxtheme.dll这三个文件被破解所导致的。解决方案是恢复它,参考:http://download.csdn.net/download/friendan/8199047
在windows下面,由于目录名称最长只有260字符,使用node gulp,grunt等模块时,往往出现Cannot mkdir: Protocol error错误
可能的解决方案参考:
http://stackoverflow.com/questions/30090691/configuring-homestead-to-work-for-windows-users/30094439#30094439
https://github.com/npm/npm/issues/3670
https://github.com/mitchellh/vagrant/pull/5495
关于UNC的知识点: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#short_vs._long_names
总结一下homestead vbox的UNC name配置解决方案:
1. comment out ~/.homestead/homestead.yaml中的文件夹共享:
# folders:
# - map: D:\devenv\code
# to: /home/vagrant/code
2. 在vagrantfile中将以下内容插入
# this should be inserted right before the "Homestead.configure()" line
config.vm.provider "virtualbox" do |v, override|
if Vagrant::Util::Platform.windows?
override.vm.synced_folder "D:\devenv\code", "/home/vagrant/code", disabled: true v.customize ["sharedfolder", "add", :id, "--name", "code", "--hostpath", (("//?/D:/devenv/code").gsub("/","\\"))] override.vm.provision :shell, inline: "mkdir -p /home/vagrant/code"
override.vm.provision :shell, inline: "mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` code /home/vagrant/code", run: "always"
else
override.vm.synced_folder "D:\devenv\code", "/home/vagrant/code"
end v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/code", ""]
end
# this should be inserted right before the "Homestead.configure()" line
除了上面的使用windows UNC来解决node/bower的长文件名问题外,对于node我们还有一种解决方案,就是使用https://github.com/arifsetiawan/flatten 这个package,来对node_modules目录进行扁平化,用法是在linux或者windows unc下彻底安装node modules后,执行下面的命令:
flatten-packages PROJECT_DIRECTORY
命令完成后,就将老的node_modules全部扁平化,彻底解决长文件名的问题!!!!同时该命令将删除老的垂直安排的module
homestead下node npm团队使用的实践探索
一般情况下,没有必要每个团队成员都完全安装node,npm以及对应的node_modules,可行的措施是将node_modules本身作为一个repo,同时将node.exe文件copy到项目的root folder(就是package.json的所在目录),这样团队成员就不用安装node以及对应的package了,又能正常做build!!
windows下除了文件名长度问题外,默认如果不是以administrator运行virtualbox的话还有无法创建symlink的问题,所以一般如果使用npm,bower自动化你的测试开发流程时,可能会由于无法在windows/virtualbox之间的共享的文件夹中创建symlink而导致一些烦人的问题,一个可行的workaround是把node module, bower module等放到非windows共享文件夹中, bower可以通过.bowerc指定bower 模块安装位置, package.json以及node_modules可以放到非win目录的一个wrapper目录中。当然,也可以通过将执行vagrant up命令的命令行以administrator身份启动也能够解决windows环境下在homestead virtualbox中不能创建symbol link的问题!!!也就是说在win10下是可以创建symlink的!
在windows操作系统中,可能需要再bios中设置intel CPU的虚拟化功能使能。
vagrant up过程中,可能出现: default: Warning: Connection timeout. Retrying..., 这时可能的解决方案是:
在vagrantfile中增加以下内容,使能gui,检查是否是停留在了grub那里:
config.vm.provider "virtualbox" do |v|
v.gui = true
end
还有一种解决方案是修改grub信息,给一个timeout超时。 http://segmentfault.com/a/1190000000266564出现这种错误,另外一个可能是你的vt没有打开,在bios中设置虚拟化有可能解决问题。还有一种方案是选择32bit的系统,具体参考: http://laravel.io/forum/05-18-2014-trouble-getting-homestead-to-start-in-windows?page=1
用 VirtualBox 面板运行该系统,在 GRUB 界面回车登录系统,用户名:vagrant
,密码:vagrant
,编辑/etc/grub.d/00_header
,找到:
if [ "\${recordfail}" = 1 ]; then
set timeout=-1
将 -1
改成 10
即可:
if [ "\${recordfail}" = 1 ]; then
set timeout=10
再运行 $ update-grub
更新 GRUB,关机后再用 $ vagrant up
启动就能正常启动了。
在windows下面如果你做好了配置,hosts文件也正确,但是一直出现no input files这个错误,可以尝试vagrant up --provision,如果确实已经up状态了,
可以只执行: vagrant provision就可以了。注意只要.yaml配置文件修改了,最好都执行vagrant reload --provision
参考: https://github.com/mitchellh/vagrant/issues/3869#issuecomment-48058728 (文件本身在网盘有备份)
当你发现虚拟机开发环境客制化满意后,你可以做的事情是将该虚拟机打包成另外一个box,以便提供给别人使用,提供一套统一的开发环境,确实不错哦:
vagrant package --output vagrant_example.box (在你的vagrantfile所在目录) 或者:
vagrant package xxpackage --output xxpackage.box --vagrantfile Vagrantfile
http://lovelace.blog.51cto.com/1028430/1423343
browsersync的watch/reload任务监听3000端口,但是我们需要增加一个forwarded port在vagrantfile中,但是有时不工作,那么可以手工在virtualbox中添加端口转发就可以了。
常用命令:
vagrant box list
vagrant init xxBox :创建vagrantfile,并且将box信息更新为xxBox
vagrant up (在有vagrantfile的目录执行)
vagrant ssh-config :在你的vagrantfile所在目录检查该vagrant box的ssh配置信息
$ vagrant ssh-config
Host default
HostName 127.0.0.1
User vagrant
Port
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile "c:/Documents and Settings/zhang/devenvironment/Homestead/.vagrant/machines/default/v
irtualbox/private_key"
IdentitiesOnly yes
LogLevel FATAL
为工作方便创建一个ssh vagrant的alias,该命令等同于在homestead目录下执行vagrant ssh
alias vm="ssh vagrant@127.0.0.1 -p 2222 -i ~/devenvironment/Homestead/.vagrant/machines/default/virt
ualbox/private_key"
同时,一旦登陆到系统后执行一个.postlogin.sh(cd xxx/yyy)目录,这样就很方便了(source调用上述脚本)
在homestead下也可以非常方便地创建新的sites:注意: 如果出现serve command not found错误的话,可以手工 source ~/.bashrc,也就是说上述serve命令就在.bashrc文件中定义的!!
vagrant@homestead:~$ serve trace.dev /home/vagrant/code/xdebug-trace-gui
dos2unix: converting file /vagrant/scripts/serve.sh to Unix format ...
nginx stop/waiting
nginx start/running, process
php5-fpm stop/waiting
php5-fpm start/running, process
console下彩色显示
alias ls='ls --color=always'
laravel homestead vagrant box安装使用,问题,及相关命令的更多相关文章
- 解决安装laravel/homestead vagrant环境报"A VirtualBox machine with the name 'homestead' already exists."的错误
之前在mac上安装laravel/homestead vagrant虚拟机环境时由于参照的教程是: 每次都必须在~/Homestead目录下边运行vagrant up/halt命令,觉得实在是不方便, ...
- 实际操作中遇到的问题--Django中查看已安装的包的相关命令
pip freeze --------查看已经安装的包 pip uninstall 安装包名 ---------卸载已安装的包 pip install 安装包名--------安装包
- linux下安装rar以及rar相关命令参数详解
Linux平台默认是不支持RAR文件的解压,需要安装Linux版本的RAR压缩软件,下载地址:http://www.rarlab.com/download.htm 下载之后进行解压之后,进入rar目录 ...
- Linux for CentOS 下的 keepalived 安装与卸载以及相关命令操作之详细教程
百度百科解释: keepalived 是一个类似于 layer3, 4 & 7 交换机制的软件,也就是我们平时说的第 3 层.第 4 层和第 7 层交换.Keepalived 的作用是检测 w ...
- Centos下Docker安装与使用的相关命令
sudo yum install -y yum-utils device-mapper-persistent-data lvm2 systemctl docker status yum-config- ...
- 同时存在两个或多个homestead 虚拟box
开发中发现,不同版本的homestead 里面的环境各不相同,里面的node,npm等版本都不一致,如果需要添加 不同版本的homestead同时存在可以按照以下办法处理. tips: 提供可以离线下 ...
- Laravel Homestead安装笔记
引言: 最近开始学习laravel框架,了解到有个laravel homestead的box,开发起来非常方便快捷,于是就准备开始配置homestead虚拟开发环境了 什么是Homestead 要想学 ...
- Laravel环境配置之安装Homestead
laravel requirements: PHP >= 5.5.9 (机器上yum安装的是5.3.3) OpenSSL PHP Extension PDO PHP Extension Mb ...
- Laravel Homestead安装教程
1/先在https://www.vagrantup.com 下载vagrantup ,对应平台下载,并安装,安装后可以在命令行使用vagrant https://www.vagrantup.com/ ...
随机推荐
- sublime text3使用心得及个人配置 sublime常用快捷键大全
下载好后:1.安装package controlimport urllib.request,os; pf = 'Package Control.sublime-package'; ipp = subl ...
- Java开发WebService的几种方法--转载
webservice的应用已经越来越广泛了,下面介绍几种在Java体系中开发webservice的方式,相当于做个记录. 1.Axis2 Axis是apache下一个开源的webservice开发组件 ...
- SQL技术内幕-10 in和exists 性能比较
in和exists in 是把外表和内表作hash 连接,而exists是对外表作loop循环,每次loop循环再对内表进行查询. 一直以来认为exists比in效率高的说法是不准确的. 如果查询的两 ...
- Android安卓开发环境搭建详细教程
安装目录:步骤1 安装JDK步骤2 安装 Android SDK ----http://www.androiddevtools.cn/ 步骤3 安装Tomcat步骤4 安装Ant步骤5 安装Eclip ...
- C语言学习资料(转载)
◆经典C源程序100例:http://post.baidu.com/f?kz=8618367 ◆时钟的驻留程序:http://post.baidu.com/f?kz=10822377 ◆数据结构暨若干 ...
- lintcode:Wiggle Sort
Wiggle Sort Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= ...
- TCP与UDP的不同接包处理方式
TCP与UDP的不同接包处理方式 1.UDP发包的问题问:udp 发送两次数据,第一次 100字节 ,第二次200字节, 接包方一次recvfrom( 1000 ), 收到是 100,还是200,还是 ...
- 8 simple things that will make you sexy
8 simple things that will make you sexy8种方法教你不动声色的性感What makes a women sexy? Is it her body? Is it t ...
- ios开发--tcp/ip
简介 该篇文章主要回顾--TCP/IP协议族中的TCP/UDP.HTTP:还有Socket.(--该文很干,酝酿了许久!你能耐心看完吗?) 我在这个文章中,列举了常见的TCP/IP族中的协议,今天主角 ...
- Phalanx--hdu2859(dp 最大对称子图)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2859 题意就是给你一个n*n的字符矩阵,从中选出一个最大的子矩阵(m*m)满足关于斜对角线(左下角到右 ...