使用Vagrant搭建本地python开发环境

关于vagrant:
Vagrant是一个基于Ruby的工具,用于创建和部署虚拟化开发环境,它使用Oracle的开源VirtualBox虚拟化系统
也可以使用vmware来搭配使用,因为配置较为繁琐放弃了(貌似需要安装一个收费插件,还不如直接安装virtualbox)

详细操作步骤:
工具及环境介绍:
工具及环境 版本 下载地址
宿主机环境 win10 x86_64 家庭版 http://msdn.itellyou.cn/
VirtualBox VirtualBox-5.2.0 https://www.virtualbox.org/
vagrant vagrant_2.0.1 http://www.vagrantup.com/
box centos-6.6-x86_64.box http://www.vagrantup.com/
xshell xshell_5.0 build 1326 http://www.netsarang.com/download/main.html

1.下载并安装软件
①下载virtualbox虚拟机,很简单就不赘述(中途需要断网,需要注意)
http://download.virtualbox.org/virtualbox/5.2.0/VirtualBox-5.2.0-118431-Win.exe

②下载并安装Vagrant
https://releases.hashicorp.com/vagrant/2.0.1/vagrant_2.0.1_x86_64.msi

③centos-6.6-x86_64.box具体地址
https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.0.0/centos-6.6-x86_64.box

2.将VirtualBox的路径配置到高级环境变量中
D:\Program Files\Oracle\VirtualBox\

通过cmd直接运行VBoxManage.exe可以启动virtualbox虚拟机程序

3.下载centos-6.6-x86_64.box放到d:/data目录下

cmd命令窗口下:
d:
cd data

①创建centos6.6-x86_64镜像
D:\data>vagrant box add "centos6.6-x86_64" centos-6.6-x86_64.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box ‘centos6.6-x86_64‘ (v0) for provider:
box: Unpacking necessary files from: file://D:/data/centos-6.6-x86_64.box
box:
==> box: Successfully added box ‘centos6.6-x86_64‘ (v0) for ‘virtualbox‘!

# 查看虚拟机列表
D:\data>vagrant box list
centos6.6-x86_64 (virtualbox, 0)

③cd到devops2目录下初始化一个box
D:\data>cd devops2

D:\data\devops2>vagrant init "centos6.6-x86_64"
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.

④启动虚拟机
D:\data\devops2>vagrant up
Bringing machine ‘default‘ up with ‘virtualbox‘ provider...
==> default: Importing base box ‘centos6.6-x86_64‘...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: devops2_default_1511436711981_49349
==> 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 (guest) => 2222 (host) (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 reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. 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 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 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.3.28
default: VirtualBox Version: 5.2
==> default: Mounting shared folders...
default: /vagrant => D:/data/devops2

# 可以看到启动了虚拟机

④启动ssh
D:\data\devops2>vagrant ssh
Last login: Sat May 30 12:27:44 2015 from 10.0.2.2
Welcome to your Vagrant-built virtual machine.

也可以通过ssh工具连接比如xshell连接127.0.0.1 的2222端口,用户名为vagrant密码选择public key选择安装目录的private_key导入即可

[[email protected] ~]$ pwd
/home/vagrant
[[email protected] ~]$ cd /vagrant


# 默认会把目录映射到/vagrant目录下
[[email protected] vagrant]$ ll
insgesamt 4
-rwxrwxrwx. 1 vagrant vagrant 3093 23. Nov 12:02 Vagrantfile

[[email protected] vagrant]$ touch reboot.txt
[[email protected] vagrant]$ echo ‘jack‘ > reboot.txt
[[email protected] vagrant]$ ll
insgesamt 5
-rwxrwxrwx. 1 vagrant vagrant 5 23. Nov 12:55 reboot.txt
-rwxrwxrwx. 1 vagrant vagrant 3093 23. Nov 12:02 Vagrantfile

⑤关闭虚拟机
关机D:\data\devops2>vagrant halt

时间: 2024-10-12 21:41:59

使用Vagrant搭建本地python开发环境的相关文章

Eclipse 下搭建pyDev python开发环境及helloworld

一,安装基础环境 1,安装jdk7,并配置环境变量(pyDev要求jdk7及以上版本,否则安装好也不显示) 2,下载Eclipse并解压 3,安装python3.X 二,Eclipse下配置pyDev 1,安装插件:help -> Install new Software.. ->输入PyDev Update Site - http://pydev.org/updates 然后下一步.同意等等. 2,配置python编译器:Window -> perferences -> pyDe

Eclipse和PyDev搭建完美Python开发环境(Windows篇)(转)

摘要:本文讲解了用Eclipse和PyDev搭建Python的开发环境. 十一长假在家闲着没事儿,准备花点时间学习一下Python. 今儿花了一个下午搭建Python的开发环境,不禁感叹————开源的东西就是麻烦啊··· 唉,可怜我们这些被微软宠坏了的开发人员··· 为什么不用别的IDE呢? IDLE是小打小闹用的,那个WingIDE是要钱的,而且用不惯.Eclipse+PyDev插件是最主流的Python开发环境了. 1.准备工作: 下载32位的JDK6 Java的开发包  我也不想装这玩意儿

ubuntu环境利用Vagrant搭建一个虚拟开发环境

Vagrant是一个搭建完整的虚拟开发环境的工具,通常简写为VDE(Virtual Development Environment).Vagrant节省大量重建操作系统环境的时间,它也是一个配置中心,允许你使用一个相同的配置管理和部署多个VDE.安装Vagrant的同时,你也需要安装VirtualBox,因为它是Vagrant的核心功能组建. 1.安装virtualboxsudo apt-get install virtualbox 2.vagrant是ruby开发的,所有安装ruby相关的东西

搭建本地SAE开发环境

为了方便开发者测试开发,SAE提供了本地开发环境,能模拟SAE的大部分功能也服务,在本地开发测试,不用频繁上 传代码,很方便 ?SAE本地开发环境可以在SAE公共资源加速网站: ?http://lib.sinaapp.com/获取,点击页面底部的下述链接即可. 那个文件夹结构 因为我之前有装过Apache,所以会有端口冲突,所以我修改了sae.config,如图: 然后运行 ok,服务器启动成功了哦 希望可以帮助学习的人哈!^V^ 

搭建本地LNMP开发环境(2.6)-使用VMware Tools共享代码

之所以这篇排序2.6,是尽可能早的确定所使用的VMware Tools是否能正常工作,如果不能,需要卸载并重新安装其他版本的VMware. VMware Tools可用来将windows下(开发环境)的代码共享到debian里(代码运行环境). (还可以通过debia中安装samba,将debian中的代码共享到windows,但是方式不能在wheezy未运行的情况下查看代码) 开始运行wheezy 连接到debian 先安装VMware Tools需要build-essential 输入 ap

搭建本地LNMP开发环境(6)-配置nginx和PHP

修改php的监听方式为监听端口 输入 vim /etc/php5/fpm/pool.d/www.conf 找到行 listen = /var/run/php5-fpm.sock 前面添加分号;注释掉这一行 然后在下面添加新行 listen = 127.0.0.1:9000 表示监听本机的9000端口 保存并退出编辑 输入 service php5-fpm restart 重启php5-fpm (php5-fpm是什么?管理php的东西,具体自己百度去) 配置nginx 输入 cd /etc/ng

Eclipse和PyDev搭建完美Python开发环境(Windows篇)

http://blog.163.com/jackie_howe/blog/static/199491347201282272155373/ 1.准备工作: 下载32位的JDK6 Java的开发包 我也不想装这玩意儿,但是Eclipse依赖他,没办法. 下载32位的Eclipse 下载Python 2.x 2.配置java环境 Java环境搭建 3.安装Eclipse和Python Eclipse是绿色软件,找个地方解压一下就OK了 Python的安装就更不用说了 4.给Eclipse安装PyDe

Eclipse和PyDev搭建完美Python开发环境 Windows篇

1,安装Python Python是一个跨平台语言,Python从3.0的版本的语法很多不兼容2版本,官网找到最新的版本并下载:http://www.python.org, 因为之前的一个项目是2版本开发的,故下载了2.7 2,在Windows命令行中使用Python 如果你想要从Windows命令行调用Python,那么需要先设置Python环境变量. 编辑PATH环节便利将;D:\dev\python2.7.11加到它的结尾.当然,是Python所在的安装目录. 3,测试python环境变量

Windows7下搭建Eclipse+Python开发环境

机器: Windows7_x86_64 前提: 机器已成功安装Python2.7,并配置好环境变量. 步骤: 一.Eclipse的安装 Eclipse是基于java的一个应用程序,因此需要一个java的运行环境(JRE). JRE的下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html 进入页面选择JRE,并选择jre-8u45-windows-x64.exe进行下载,下载完成后双击即可安装. Eclipse