参考地址1: http://segmentfault.com/blog/fenbox/1190000000264347
参考地址2: http://blog.phpor.me/2014/10/12/vagrant-%E6%9C%AC%E5%9C%B0%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83.html
下载的系统是centos6.3 64位: https://s3.amazonaws.com/itmat-public/centos-6.3-chef-10.14.2.box
Vagrant 是一款用来构建虚拟开发环境的工具,非常适合 php/python/ruby/java 这类语言开发 web 应用,“代码在我机子上运行没有问题”这种说辞将成为历史。
我们可以通过 Vagrant 封装一个 Linux 的开发环境,分发给团队成员。成员可以在自己喜欢的桌面系统(Mac/Windows/Linux)上开发程序,代码却能统一在封装好的环境里运行,非常霸气。
以下是实战内容:
Last login: Tue Mar 24 14:20:44 on console ➜ ~ ls AFNetworking Documents Music Rainforest install.log swift_language_learning.md AndroidStudioProjects Downloads PhpstormProjects VirtualBox VMs mbox t.txt Applications Library Pictures a.php myfile.in test.awk Desktop Movies Public dead.letter paros ➜ ~ cd Documents/vagrant_maxwelldu ➜ vagrant_maxwelldu ls movienext ➜ vagrant_maxwelldu cd movienext ➜ movienext ls ➜ movienext ll ➜ movienext vagrant box add base ~/Downloads/centos-6.3-chef-10.14.2.box ==> box: Adding box 'base' (v0) for provider: box: Downloading: file:///Users/michaeldu/Downloads/centos-6.3-chef-10.14.2.box ==> box: Successfully added box 'base' (v0) for 'virtualbox'! ➜ movienext ls ➜ movienext ll ➜ movienext vagrant box list base (virtualbox, 0) ➜ movienext vagrant init base A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant. ➜ movienext ll total 8 -rw-r--r-- 1 michaeldu staff 3016 Mar 24 16:00 Vagrantfile ➜ movienext vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'base'... ==> default: Matching MAC address for NAT networking... ==> default: Setting the name of the VM: movienext_default_1427184057998_56337 ==> 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 for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Warning: Connection timeout. Retrying... default: Warning: Remote connection disconnect. Retrying... default: default: Vagrant insecure key detected. Vagrant will 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 its 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 do not match the installed version of default: VirtualBox! In most cases this is fine, but in rare cases it can default: prevent things such as shared 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 have installed on default: your host and reload your VM. default: default: Guest Additions Version: 4.1.22 default: VirtualBox Version: 4.3 ==> default: Mounting shared folders... default: /vagrant => /Users/michaeldu/Documents/vagrant_maxwelldu/movienext ➜ movienext vagrant ssh Last login: Fri Sep 14 17:53:41 2012 from 10.0.2.2 [vagrant@localhost ~]$ cd /va vagrant/ var/ [vagrant@localhost ~]$ cd /va vagrant/ var/ [vagrant@localhost ~]$ cd /vagrant/ [vagrant@localhost vagrant]$ wget http://www.baidu.com --2015-03-24 09:02:48-- http://www.baidu.com/ Resolving www.baidu.com... ^C [vagrant@localhost vagrant]$ exit logout Connection to 127.0.0.1 closed. ➜ movienext vim Vagrantfile ➜ movienext vagrant reload ==> default: Attempting graceful shutdown of VM... ==> 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: Adapter 2: hostonly ==> default: Forwarding ports... default: 22 => 2222 (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Warning: Connection timeout. Retrying... ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM... default: The guest additions on this VM do not match the installed version of default: VirtualBox! In most cases this is fine, but in rare cases it can default: prevent things such as shared 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 have installed on default: your host and reload your VM. default: default: Guest Additions Version: 4.1.22 default: VirtualBox Version: 4.3 ==> default: Configuring and enabling network interfaces... ==> default: Mounting shared folders... default: /vagrant => /Users/michaeldu/Documents/vagrant_maxwelldu/movienext ==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision` ==> default: to force provisioning. Provisioners marked to run always will still run. ➜ movienext vagrant ssh Last login: Tue Mar 24 09:01:32 2015 from 10.0.2.2 [vagrant@localhost ~]$ ping www.baidu.com PING www.a.shifen.com (61.135.169.125) 56(84) bytes of data. 64 bytes from 61.135.169.125: icmp_seq=1 ttl=63 time=5.12 ms 64 bytes from 61.135.169.125: icmp_seq=2 ttl=63 time=5.86 ms 64 bytes from 61.135.169.125: icmp_seq=3 ttl=63 time=4.77 ms ^C --- www.a.shifen.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2112ms rtt min/avg/max/mdev = 4.775/5.255/5.867/0.459 ms
到这里把vagrant安装好了, 进去了, 后面还需要安装lnmp
nginx安装参考地址: http://blog.csdn.net/stuartjing/article/details/8124491
nginx对应版本地址: http://nginx.org/en/download.html
安装好了之后,
vagrant box list vagrant box add base ~/Downloads/centos-6.3-chef-10.14.2.box vagrant init base vi Vagrantfile config.vm.network "private_network", ip: "192.168.33.10" vagrant up vagrant ssh sudo su - yum search mysql yum -y install mysql mysql-devel mysql-server php-mysql service mysqld start /usr/bin/mysqladmin -u root password 'root' mysql -uroot -proot netstat -tunpl mysql -uroot -proot use mysql select Host, User, Password from user; update user set Host='%' where User='root' And Host='127.0.0.1'; update user set Password=password('root'); select Host, User, Password from user; flush privileges; exit service mysqld restart /etc/init.d/iptables stop chkconfig --levels 35 iptables off yum -y install php php-gd php-fpm php-pdo yum search nginx yum -y install nginx /etc/init.d/php-fpm restart
相关推荐
Docker和Vagrant经常被认为是两种相互替代的工具,其实它们可以结合使用,构建隔离的、可重复的开发环境。我们将证明该环境可以构建一个Docker容器以便开发Java应用程序,并充分利用Vagrant的强大功能,以解决一些...
vagrantpress, vagrant/Puppet的WordPress开发环境 VagrantPressVagrantPress 是开发WordPress主题和模块的打包开发环境。我最初创建这个项目是为了帮助开发一个WordPress博客的子模块。安装了什么Ubuntu信任( 14 04...
Vagrant提供了可配置、可复用的虚拟开发和部署环境,对于开发人员来说,Vagrant可以帮你统一团队成员的开发环境。也可以提供一套一致的线上线下环境。vagrant 在mac上通过命令行工具可以管理统一的镜像(BOX)所以...
这个 repo 旨在保存一些 Ansible 剧本和角色,以使用 Vagrant 构建我的开发环境。 角色 rails-dev 角色 该角色将 Debian/Ubuntu 机器转变为开发 Ruby Web 应用程序(Ruby on Rails、Sinatra 等)的环境。 它依赖于...
开发环境dev.env是一个零设置开发环境。 它所执行的功能与所命名的功能完全相同,可帮助您快速创建开发环境,而无需进行设置-dev.env将为您设置并启动所有内容。现在支持什么平台? 当前,仅Mac OS X已过测试。 请帮...
GantSign EnV 使用Vagrant构建的Java,Python,Node.js和Go开发环境。关于正确设置开发环境是一个耗时且容易出错的过程。 让团队中的每个人正确设置他们的环境更具挑战性。 该项目的目标是使建立开发环境可靠且可...
vagrant-golang, 一个很容易使用的golang环境,可以与vagrant一起使用 Golang Vagrant环境其他语言相比,Golang 有稍微复杂一点的设置过程,因为它使用了一个基于xml的工作区概念。 使环境错误意味着许多go命令会...
vagrant centos7 镜像
流浪汉此仓库包含一个Vagrantfile,用于设置简单的go环境以启动并运行go开发。 只需Vagrant。 为您的项目创建一个主文件夹。 将Vagrantfile复制到根目录。 vagrant up 现在,您可以运行vagrant ssh来访问您的计算机...
vagrant-rackspace, 使用Vagrant管理Rackspace云实例 Vagrant云提供商这是一个 Vagrant 插件that向Vagrant添加一个云提供程序,允许Vagrant控制和供应Rackspace云中的计算机。注意:这个插件需要 Vagrant 。 Windows...
由Vagrant管理的开发环境可以在本地虚拟平台(例如VirtualBox或VMware)上运行,可以通过AWS或OpenStack在云中运行,也可以在诸如Docker或原始LXC的容器中运行。 Vagrant提供了用于创建和管理的框架和配置格式
ansible-vagrant-examples, 使用Vagrant部署到本地vm的Ansible示例 Ansible Vagrant示例这个库包含运行各种应用程序的示例虚拟机的Collection 。 vm是通过Vagrant创建的,通过Ansible提供。你可以以在任何包含的目录...
使用Vagrant和Virtualbox搭建Kubernetes集群
plonedev.vagrant, 一家plone开发公司的Vagrant设置 PloneDev.VagrantPloneDev.Vagrant 是在托管虚拟机中为Plone设置易于使用的开发环境的工具包。这个工具包使用了虚拟机和Vagrant盒安装系统。 它应该在任何有...
关于使用 vagrant 设置 AOSP 开发环境的演示 数据于年举行的展示。 跑步 $ git clone https://github.com/chitacan/aosp-build-with-vagrant $ cd aosp-build-with-vagrant $ npm install $ grunt 在浏览器中访问...
vccw, 基于Vagrant的开发环境 VCCW 这是为开发WordPress插件。主题或者网站而设计的Vagrant配置。要开始,请查看 http://vccw.cc/ 。配置将 provision/default.yml 复制到 site.yml 。编辑 s
该项目致力于PrestaShop模块和主题开发人员,他们正在寻找坚如磐石且易于设置的开发环境。 目录 总览 PrestaShop PrestaShop是一个免费的开源电子商务Web应用程序,致力于为商人和客户提供最佳的购物车体验。 它是...
devenv-old我不再使用它了之前在 Ubuntu 上创建了一个运行在 Vagrant 上的开发环境,但是由于以下事件,我决定再次在 Mac 上创建一个开发环境。 不能使用bundle open 使用“gulp-watch”或“nodemon”时未检测到文件...
流浪狂欢 使用Vagrant的Spree开发环境。 基本作业系统:Ubuntu 14.04(Trust)64 Ruby:2.2.1 Ruby on Rails:4.2.1 邮编:9.3