下载vagrant软件包 地址, 安装(windows傻瓜式安装, 很少说).php
建立vagrant工程目录, 初始化Vagrantfile.html
F:\> mkdir vagrant F:\> cd vagrant F:\vagrant>vagrant.exe init 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.
添加box(相似docker的容器), 到官方源下载须要的box, 本案例下载(puppetlabs/centos-6.6-64-nocm)(https://atlas.hashicorp.com/puppetlabs/boxes/centos-6.6-64-nocm),公司服务器是centos6.x.mysql
F:\vagrant>vagrant box add puppetlabs/centos-6.6-64-nocm ==> box: Loading metadata for box 'puppetlabs/centos-6.6-64-nocm' box: URL: https://atlas.hashicorp.com/puppetlabs/centos-6.6-64-nocm This box can work with multiple providers! The providers that it can work with are listed below. Please review the list and choose the provider you will be working with. 1) virtualbox 2) vmware_desktop Enter your choice: 1 ==> box: Adding box 'puppetlabs/centos-6.6-64-nocm' (v1.0.3) for provider: virtualbox box: Downloading: https://atlas.hashicorp.com/puppetlabs/boxes/centos-6.6-64-nocm/versions/1.0.3/providers/virtualbox.box box: Progress: 0% (Rate: 27052/s, Estimated time remaining: 3:23:32)==> box: Waiting for cleanup before exiting... box: Progress: 0% (Rate: 23813/s, Estimated time remaining: 3:26:33) ==> box: Box download was interrupted. Exiting.
ps: 慢的有的一B啊, 果断复制连接, 迅雷下载, 安装*.box文件. 速度还能接受.
linux
box命令略解: vagrant box add [可选参数] <官方源名称, url连接地址, 下载后的*.box文件>
web
安装box文件(秒干):sql
F:\vagrant>vagrant box add --name puppetlabs/centos-6.6-64-nocm F:\boxes\virtualbox.box ==> box: Box file was not detected as metadata. Adding it directly... ==> box: Adding box 'puppetlabs/centos-6.6-64-nocm' (v0) for provider: box: Unpacking necessary files from: file://F:/boxes/virtualbox.box box: Progress: 100% (Rate: 658M/s, Estimated time remaining: --:--:--) ==> box: Successfully added box 'puppetlabs/centos-6.6-64-nocm' (v0) for 'virtualbox'!
使用刚下在的boxdocker
编辑vagrant工程目录下的Vagrantfile文件apache
15行: config.vm.box = "puppetlabs/centos-6.6-64-nocm"
启动vagrant(此处会启动virtualbox, 预先安装virtualbox, win7安装有点小问题, 请自行google或百度解决)windows
vagrant up
ssh上去(默认F:/vagrant 自动挂载到/vagrant)上centos
F:\vagrant>vagrant ssh Last login: Fri May 6 02:33:11 2016 from 10.0.2.2 [vagrant@localhost ~]$ ls / bin boot dev etc home lib lib64 lost+found media mnt opt proc root sbin selinux srv sys tmp usr vagrant var [vagrant@localhost ~]$
在/vagrant建立的文件, 会同步到 F:>vagrant下.
本案列使用 apache2.4, php5.6.12 mysql5.7 编译安装, 源文件都一打包好, 有须要能够找我要loovien@163.com.
默认全部服务安装到/usr/local/webserver目录下.
安装必要的依赖.
$ sudo yum groupinstall "Development tools"
apache2.4 编译.
./configure && make && make install
../configure --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache --enable-expires --enable-headers --enable-usertrack --enable-cgi --enable-vhost-alias --enable-rewrite --enable-so --with-include-apr --prefix=/usr/local/webserver
, make && make install
编译php
安装依赖, 没办法, 编译就是这样, 少了什么依赖就安装什么依赖, 编译安装.
$ sudo yum install libxml2 libxml-devel
$ ./configure --prefix=/usr/local/webserver/php --with-mysql
$ make && make install
编译mysql
运行项目可能须要编译php扩展, 自行安装便可, 使用 phpize
.
在/etc/rc.local, 添加apache2, mysql 启动命令, 是开机启动.